补全库
完成让您:
- 监控和调试您的 LLM 提示在生产中 .
- 跟踪 LLM 模型的使用和成本.
关键特性
- 监视提示: 实时跟踪发送给您的 LLM 模型的提示 。 我们有意将即时参数从即时模板中分出,以确保您可以监视提示,自动检测版本变化,并调试历史数据上的问题.
- 费用追踪:跟踪您的 LLM 模型的使用和成本。 我们详细列出了每起急车的费用,包括模型费用、急车费用和总费用.
- 版本控制: 管理您提示的版本。 我们自动检测快速模板和参数的更改,允许您跟踪您提示随时间推移的演变情况.
安装
使用 npm 或纱线安装补全节点库 :
npm install @completionhq/completion-node
# or
yarn add @completionhq/completion-node
使用量
下面是演示如何在您的节点.js应用程序中使用补全的示例 .
完成是LLM-agnostic,意思是它可以和任何LLM模型一起使用,包括来自OpenAI,Anthropic,Google,Mistral等的.
基本日志
import { Completion } from '@completionhq/completion-node';
const completion = new Completion({
apiKey: 'abc123',
});
const messagesTemplate = [
{
role: 'User',
message: 'Hello, how are you {name}?',
},
{
role: 'Assistant',
message: 'I am good, thank you. How can I help you today?',
},
];
const promptArguments = {
name: 'Alice',
};
const output = "Is there anything I can help you with today?";
await completion.log({
templateName: 'greeting',
messagesTemplate,
promptArguments,
output,
model: 'gpt-3.5-turbo',
});
记录已编译的快件
const compiledMessages = [
{
role: 'User',
message: 'Hello, how are you Alice?',
},
{
role: 'Assistant',
message: 'I am good, thank you. How can I help you today?',
},
];
await completion.log({
templateName: 'greeting',
compiledMessages,
output,
model: 'gpt-3.5-turbo',
});
使用已编译的快速日志
const compiledPrompt = "User: Hello, how are you Alice?\nAssistant: I am good, thank you. How can I help you today?";
await completion.log({
templateName: 'greeting',
compiledPrompt,
output,
model: 'gpt-3.5-turbo',
});