DeepInfra
LangChain 通过 DeepInfra
包装器支持由 Deep Infra 托管的 LLMs。首先,您需要安装 @langchain/community
包
提示
参见 有关安装集成包的通用说明的此部分。
- npm
- Yarn
- pnpm
npm install @langchain/community
yarn add @langchain/community
pnpm add @langchain/community
您需要获取 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 });
API 参考
- DeepInfraLLM 来自
@langchain/community/llms/deepinfra