作者
LangChain.js 支持调用 作者 LLMs。
设置
首先,您需要在 https://writer.com/ 上注册一个帐户。创建服务帐户并记下您的 API 密钥。
接下来,您需要将官方包作为对等依赖项安装
- npm
- Yarn
- pnpm
yarn add @writerai/writer-sdk
yarn add @writerai/writer-sdk
yarn add @writerai/writer-sdk
提示
- npm
- Yarn
- pnpm
npm install @langchain/community @langchain/core
yarn add @langchain/community @langchain/core
pnpm add @langchain/community @langchain/core
用法
import { Writer } from "@langchain/community/llms/writer";
const model = new Writer({
maxTokens: 20,
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.WRITER_API_KEY
orgId: "YOUR-ORGANIZATION-ID", // In Node.js defaults to process.env.WRITER_ORG_ID
});
const res = await model.invoke(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });
API 参考
- 作者 来自
@langchain/community/llms/writer