Writer
LangChain.js 支持调用 Writer 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
yarn add @langchain/community
pnpm add @langchain/community
使用
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 参考
- Writer 来自
@langchain/community/llms/writer