npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

langchain-siliconflow

v0.1.7

Published

LangChain.js provider integration for SiliconFlow (chat + embeddings).

Readme

langchain-siliconflow

这不是官方的 LangChain.js 适配包,而是一个社区维护的项目。

LangChain.js 的 SiliconFlow 适配包(Chat + Embeddings)。接口兼容 @langchain/* 的常规使用方式。

安装

npm i langchain-siliconflow @langchain/core

要求 Node.js >= 18(内置 fetch)。

使用示例

Chat 模型

import { ChatSiliconFlow } from "langchain-siliconflow";
import { HumanMessage } from "@langchain/core/messages";

const chat = new ChatSiliconFlow({
  apiKey: process.env.SILICONFLOW_API_KEY!,
  model: "Qwen/QwQ-32B",
  temperature: 0.7,
});

const res = await chat.invoke([new HumanMessage("用一句话解释LangChain是什么?")]);
console.log(res.content);

Embeddings 模型

import { SiliconFlowEmbeddings } from "langchain-siliconflow";

const embeddings = new SiliconFlowEmbeddings({
  apiKey: process.env.SILICONFLOW_API_KEY!,
  model: "BAAI/bge-large-zh-v1.5",
});

const vector = await embeddings.embedQuery("你好,世界");
console.log(vector.length);

获取模型列表

依赖 ChatSiliconFlow 内置的 models 接口(或直接使用导出的 SiliconFlowModelsAPI)。

import { ChatSiliconFlow } from "langchain-siliconflow";

const chat = new ChatSiliconFlow({
  apiKey: process.env.SILICONFLOW_API_KEY!,
  model: "Qwen/QwQ-32B",
});

// 列出全部模型
const all = await chat.models.list();
console.log(all.data.map((m) => m.id));

// 仅过滤聊天模型
const chats = await chat.models.list({ type: "chat" });
console.log(chats.data.length);

静态方式获取模型列表(无需初始化 Chat)

import { ChatSiliconFlow } from "langchain-siliconflow";

// 获取全部模型
const all = await ChatSiliconFlow.listModels({
  apiKey: process.env.SILICONFLOW_API_KEY!,
});
console.log(all.data.map((m) => m.id));

// 按类型过滤(例如仅聊天模型)
const chats = await ChatSiliconFlow.listModels({
  apiKey: process.env.SILICONFLOW_API_KEY!,
  type: "chat",
});
console.log(chats.data.length);

也可以直接使用 SiliconFlowModelsAPI

import { SiliconFlowClient, SiliconFlowModelsAPI } from "langchain-siliconflow";

const client = new SiliconFlowClient({ apiKey: process.env.SILICONFLOW_API_KEY! });
const modelsApi = new SiliconFlowModelsAPI(client);
const { data } = await modelsApi.list({ type: "embedding" });
console.log(data.map((m) => m.id));

环境变量

  • SILICONFLOW_API_KEY: 在 SiliconCloud 控制台创建的 API Key。
  • 如需切换域名,可通过构造参数 baseUrl 自定义(默认 https://api.siliconflow.cn/v1)。

发布到 npm

发布前检查:

  • 确认 package.jsonnameversiondescriptionlicensefilestypesmain 等正确;已配置 publishConfig.access: "public"
  • 确认只发布 distREADME.mdfiles 已限制)。
  • 运行构建:npm run build

发布步骤:

  • 登录 npm:npm login(如果开启 2FA,请使用一次性验证码)。
  • 如需升版本:npm version patch(或 minor/major)。
  • 发布:npm publish --access public

发布后验证:

  • npm info langchain-siliconflow 查看版本与元数据。
  • 在示例工程中安装验证:npm i langchain-siliconflow @langchain/core,运行示例。

参考

  • SiliconFlow Chat Completions: https://docs.siliconflow.com/en/api-reference/chat-completions/chat-completions
  • SiliconFlow Embeddings: https://docs.siliconflow.cn/en/api-reference/embeddings/create-embeddings
  • LangChain JS DeepSeek: https://www.npmjs.com/package/@langchain/deepseek