@godspideai/cognate-profile-copilot(英语:
副驾驶参考简介:由已存在的Cognate套件所构成的完整交互式聊天应用程序——模型与工具代理循环,人类认可,浏览器服务的前端工具,共享状态和文物预测,AG-UI端点,以及React/Astryx表面. 它不添加新的内核或运行时间原始;每块都是一个也可以单独使用的包.
何时使用此软件包 : 您想要工作聊天- copilot 骨架( 流回、 批准后端工具、 浏览器服务工具、 基因UI ) 在编组您自己的工具之前, 运行为当前或研究 。 对于一个自主的会话和排程样式代理,请参见 @godspeedai/cognate-profile-harness。 。 。 .
安装
bun add @godspeedai/cognate-profile-copilot
要求数 阿宝 ++ 1.4.0和++++ 反应 19.3.0 与 反应-比分 19.3.0 (均被宣布为同级依赖). 其基础是 @godspeedai/cognate-runtime-bun, (中文(简体) ), @godspeedai/cognate-ag-ui, (中文(简体) ), @godspeedai/cognate-react,以及 @godspeedai/cognate-ui-astryx; 模型连接到 @godspeedai/cognate-provider-openai-compatible。 。 。 .
快开始
import { createClient } from "@godspeedai/cognate-client";
import { openAICompatible } from "@godspeedai/cognate-provider-openai-compatible";
import { COPILOT_AGENT, createCopilotApp, GenerativeSurface } from "@godspeedai/cognate-profile-copilot";
const app = await createCopilotApp({
store: "./copilot.sqlite",
model: openAICompatible({
id: "main",
baseURL: process.env.MODEL_BASE_URL!,
model: "my-model",
apiKey: () => process.env.MODEL_API_KEY!, // read per request, never stored
}),
instructions: "You are a support copilot.",
backendTools: [
{
contract: { id: "refund.approve", version: "1.0.0" },
description: "Issue a refund",
inputSchema: { type: "object" },
handler: (input) => ({ refunded: (input as { amount: number }).amount }),
requiresApproval: true, // pauses the run as a human-approval continuation
statePatch: (input) => [{ op: "add", path: "/refund", value: { amount: (input as { amount: number }).amount, status: "refunded" } }],
render: (input) => ({ component: "RefundCard", props: { amount: (input as { amount: number }).amount } }),
artifact: (input, output) => ({ name: "refund-receipt.json", mediaType: "application/json", content: JSON.stringify({ request: input, result: output }) }),
},
],
frontendTools: [{ name: "map.focus", description: "Focus the map", inputSchema: { type: "object" } }],
});
// Serve the AG-UI endpoint (SSE) for browser clients:
Bun.serve({ port: 3000, fetch: app.agUi });
连接客户端服务 map.focus 并且决定批准:
import { useCapability } from "@godspeedai/cognate-react";
const caller = { actor: { id: "alice", kind: "user" }, tenant: "tenant-a" };
const client = createClient({ service: app.runtime.service, caller });
client.provideCapability("map.focus", (input) => ({ centered: true }));
// Or per component lifetime:
function MapTool() {
useCapability("map.focus", (input) => ({ centered: true }));
return null;
}
// Render a run's generative-UI events with your own component registry:
function Surface({ runId }: { runId: string }) {
return <GenerativeSurface runId={runId} components={{ RefundCard: (props) => <b>Refund of {String(props.amount)}</b> }} />;
}
一个未知的组件名称使得一个占位符而不是抛出,而表面在服务器侧渲染下工作,因为客户端将它的缓冲事件重放到第一个订阅中.
剖面图的内容
| 关切 | 备份软件包 |
|---|---|
| 运行时间, 持久运行 | @godspeedai/cognate-runtime-bun |
| 续作(核准) | @godspeedai/cognate-continuations |
| 前端能力 | @godspeedai/cognate-runtime-api |
| 状态/艺术预测 | @godspeedai/cognate-client |
| AG- UI 端点 | @godspeedai/cognate-ag-ui |
| 反应绑定 | @godspeedai/cognate-react |
| 界面表面 | @godspeedai/cognate-ui-astryx |
导出 copilotProfile 财务报告和审定财务报表 copilotRegistry 按名称宣布这一组成(resolveProfile 从 @godspeedai/cognate-profile 解决现有软件包的每个条目) COPILOT_AGENT 是内置代理 id (agent.copilot) (中文(简体) ).
在运行中,副驾驶代理流模型输出为 message.delta,通过能力合同引用核准的后端工具,为客户服务前端工具作为续作,并发布 state.changed, (中文(简体) ), ui.render,以及客户可以折叠成共享状态,基因UI,以及文物列表的文物事件. 运行在完全应用程序重新启动后幸存:等待续作在他们离开的地方恢复.
限制
- 内置的 AG- UI 端点认证与开发
Bearer <tenant>:<user>象征性的大会——带来自己的authenticate(编)createAgUiHandler从@godspeedai/cognate-ag-ui直接的) 对于任何真实的. - 每个应用实例一个副驾驶代理;多代理线路由您添加.
requiresApproval仅凭人类决定的大门——没有制定自动批准或授权政策.
相关软件包
@godspeedai/cognate-profile-harness——自主剖面(工具,调度器,沙盒,子剂).@godspeedai/cognate-provider-openai-compatible—— 被createCopilotApp。 。 。 .@godspeedai/cognateSDK伞.
许可证
阿帕奇 - 2.0