跳到主要内容
LangChain 通过 DeepInfra 包装器支持由 Deep Infra 托管的 LLM。首先,你需要安装 @langchain/community 包。
有关安装 LangChain 软件包的一般说明,请参阅此部分
npm
npm install @langchain/community @langchain/core
你需要获取一个 API 密钥并将其设置为名为 DEEPINFRA_API_TOKEN 的环境变量(或将其传入构造函数),然后按照如下所示调用模型
import { DeepInfraLLM } from "@langchain/community/llms/deepinfra";

const apiKey = process.env.DEEPINFRA_API_TOKEN;
const model = "meta-llama/Meta-Llama-3-70B-Instruct";

const llm = new DeepInfraLLM({
  temperature: 0.7,
  maxTokens: 20,
  model,
  apiKey,
  maxRetries: 5,
});

const res = await llm.invoke(
  "What is the next step in the process of making a good game?"
);

console.log({ res });

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.