[RFC] 028 - 插件四期 · 流式 Tools Calling #1310
Replies: 7 comments 14 replies
-
目前是不是会把插件信息放到请求的系统提示里? |
Beta Was this translation helpful? Give feedback.
-
Tool Calls 标准示例:
平行调用示例;
|
Beta Was this translation helpful? Give feedback.
-
流式tool calls 核心要解决的问题: 1. 如何选择后端发给前端的协议?ai/sdk 的协议不可用,缺少服务端方案和客户端方案。 最终采用 SSE 标准规范 (Server-Sent Events 教程 - 阮一峰):
![]() Dev tools 很方便查看,并且 2 也好做 2. 如果直接输出,那么会导致一次读取的 token 量是全的 (如何标准化解析 SSE 结果?)![]() 使用 import { fetchEventSource } from '@microsoft/fetch-event-source';
await fetchEventSource(url, {
// ...
onmessage: (ev) => {
const data = JSON.parse(ev.data);
switch (ev.event) {
case 'text': {
output += data;
options.onMessageHandle?.({ text: data, type: 'text' });
break;
}
case 'tool_calls': {
if (!toolCalls) {
toolCalls = [];
}
options.onMessageHandle?.({
tool_calls: parseToolCalls(toolCalls, data),
type: 'tool_calls',
});
}
}
},
}); 3. Tool Calls 如何应该如何流式解析? |
Beta Was this translation helpful? Give feedback.
-
新流式协议 Provider CheckListOpenAI 兼容 Provider
Claude 类
其他
|
Beta Was this translation helpful? Give feedback.
-
一些问题记录各个 Provider 存在的千奇百怪的 Tool Calling 问题 |
Beta Was this translation helpful? Give feedback.
-
Anthropic 的 Stream 参考
Tool Calling 非流式数据:
|
Beta Was this translation helpful? Give feedback.
-
Bedrock 流式ClaudeBedrock 的 Claude 的接口最终返回的 json 和 Anthropic 的一致 Llama
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
背景
Provider Function Calling ( Tool Calling ) 支持
最近 Claude3 支持了 fc,大量用户希望为Claude3 系列模型支持上插件能力。
Google Gemini 1.5 pro最近也正式发布了,号称也完整支持了 function calling
用户对其他 Provider 的 Function Calling 需求:
未来 FC 会成为顶级模型的必备高级能力,因此需要为其可扩展性做好准备
message 数据结构升级
OpenAI 在 1106 时废弃了 role=function,改为 role=tool, 这针对一些场景做了很好的修正(比如重复调用),我们需要改造成新方式。
集成ai
SDK 的新流式协议Warning
经调研,该方案不可行
最近出的一个 bug 是
[email protected]
做了流式传输协议变更导致的( vercel/ai#1316 )。他们的初心是希望做更强大的流式能力支持,但造成了 Breaking Change。但他们在尝试做的新的流式协议可以区分出是 普通 text 还是 fc。如果基于这个新的协议,我们有机会实现体验更好的 fc 执行交互与可维护性更加的 fc 实现,这样之前尝试的 #1810 应该就可以比较顺畅的实现了。
Tool Calling 流式协议
自行实现兼容 Text 、 Tool Calling 的流式协议
Beta Was this translation helpful? Give feedback.
All reactions