@amaster.ai/副驾驶-客户端
支持 : Vite / 浏览器 / Taro H5 / Taro 小型程序 (自动发现)
安装
pnpm add @amaster.ai/copilot-client
同伴依赖关系
pnpm add @a2a-js/sdk
使用量
import { createHttpClient } from "@amaster.ai/http-client";
import { createCopilotClient, type ServerToClientMessage } from "@amaster.ai/copilot-client";
const http = createHttpClient();
const client = createCopilotClient(http);
for await (const messages of client.chat([{ role: "user", content: "Hello" }])) {
// messages: ServerToClientMessage[]
// Process/render the messages
}
API 密码
createCopilotClient(http)
创建副驾驶客户端.
client.chat(messages, options?)
流出从 A2A 响应中转换的消息 .
interface ChatMessage {
role: "system" | "user" | "assistant";
content: string | MessageContent[];
}
interface ChatOptions {
taskId?: string;
}
client.cancelChat(taskId)
取消正在进行的聊天任务.
client.getChatStatus(taskId)
获取聊天任务的当前状态.
多式联运输入
// Text
{ role: "user", content: "Hello" }
// Image
{ role: "user", content: [
{ type: "text", text: "What's this?" },
{ type: "image", url: "https://..." }
]}
// File
{ role: "user", content: [
{ type: "file", url: "https://...", name: "doc.pdf" }
]}
参考资料
许可证
麻省理工学院