@godspideai/ cognate- professor- 本地化
一个确定性,规则性规范的Cognate应用程序模型提供商. 它从规则来回答 ——没有网络,没有模型权重,没有随机性: 同一请求总是产生 相同的反应和相同的溪流块.
何时使用此软件包 : 试验和装置 ModelProvider 没有
外部依赖、离线演示和本地开发,然后指向一个真实的应用程序
终点 它从来不是一个真正的模型——不要在真正的模型行为很重要的地方使用它.
用于真正的终点, 使用
@godspeedai/cognate-provider-openai-compatible。 。 。 .
安装
bun add @godspeedai/cognate-provider-local
要求数 阿宝 >= 1.4.0. SDK 船 Bun-native TypeScript源, 因此添加
@types/bun 财务报告和审定财务报表 @types/node 在检查您的工程时, 作为非依赖性 .
快开始
import { localProvider } from "@godspeedai/cognate-provider-local";
const provider = localProvider({
id: "demo", // provider id becomes `local:demo`
rules: [
{
when: "refund", // matches a case-insensitive substring of the last user message
respond: () => ({
message: { role: "assistant", content: "Your refund is approved." },
toolCalls: [],
finishReason: "stop",
}),
},
{
// no `when`: matches everything the earlier rules did not
respond: () => ({
message: { role: "assistant", content: "Say 'refund' to exercise the flow." },
toolCalls: [],
finishReason: "stop",
}),
},
],
});
const response = await provider.generate({
messages: [{ role: "user", content: "Can I get a refund?" }],
});
console.log(response.message.content); // "Your refund is approved."
console.log(response.model); // "local-rules"
// Streaming yields the same content in text deltas (default 16 chars), then `done`
// with the exact response `generate` would return.
for await (const delta of provider.stream({ messages: [{ role: "user", content: "refund please" }] })) {
if (delta.type === "text") process.stdout.write(delta.text);
}
规则按顺序匹配: when (始终是被允许的手段)
最后用户消息的子字符串生成响应. 规则 respond 获得全部
请求并可能返回工具调用,所以脚本工具使用流也起作用。 没有匹配规则,
提供者返回一个固定的“无脚本答复”.
供应商表面
id数字 :local:<id ?? "default">· ;model: 常数"local-rules"。 。 。 .- 宣布的地物:
stream, (中文(简体) ),tool_use,以及structured_output为:true· ;multimodal_input实值false· ;context_limit实值8192。这些旗帜是固定的,不管 将预期设定在自己的资格规则中 问题. chunkSize(默认)16控制流式文本-delta长度.
限制
- 匹配只是子字符串:没有嵌入,没有排名,没有早期消息的内存.
- 它宣称工具使用和结构化输出支持,尽管由你的规则决定什么 实际上是回来的,没有任何东西能证明 脚本上的反应与这些旗帜相符.
- 绝不在需要真正模型判断的生产道路上使用它 设计.
相关软件包
@godspeedai/cognate-capabilities—— 说 页:1ModelProvider合同和选择引擎 此提供者的工具.@godspeedai/cognate-provider-openai-compatible—— 说 真正的 OpenAI 兼容 HTTP 端点的提供者.@godspeedai/cognate-runtime-bun—— 说 引用运行时间; 通过一个提供者给代理商一个模型.@godspeedai/cognateSDK伞.
许可证
阿帕奇 - 2.0