toolcall-gateway :让不支持function call的模型支持function call

2026-04-11 10:500阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

分享一个从我的web2api项目抽离出来的python库(已发布pypi):toolcall-gateway
作用:让不支持function call的模型支持function call

原理:

flowchart LR O["你的 SDK / 网关 / HTTP 层"] --> A["OpenAI-style 输入\nmessages + tools + tool_choice"] H["历史工具语义\nassistant tool_calls + tool results"] --> A subgraph T1["tool2text"] B["build_prompt / build_tagged_prompt"] C["normalize_tool_choice\nselect_tools_for_choice"] end A --> B C --> B B --> P["Tagged Prompt\n严格标签协议"] P --> M["纯文本大模型\n不支持 native function calling"] M --> X["非流式文本\n<think> / <tool_calls> / <final_answer>"] M --> Y["流式 chunk"] subgraph T2["text2tool"] D["parse_tagged_output\nparse_to_openai_assistant_turn"] E["TaggedStreamParser"] end X --> D Y --> E C --> D C --> E D --> R["OpenAI-style 输出\ncontent / tool_calls / finish_reason"] E --> R R --> O S["models.py\nOpenAI DTOs"] -.共享模型.

阅读全文
问题描述:

分享一个从我的web2api项目抽离出来的python库(已发布pypi):toolcall-gateway
作用:让不支持function call的模型支持function call

原理:

flowchart LR O["你的 SDK / 网关 / HTTP 层"] --> A["OpenAI-style 输入\nmessages + tools + tool_choice"] H["历史工具语义\nassistant tool_calls + tool results"] --> A subgraph T1["tool2text"] B["build_prompt / build_tagged_prompt"] C["normalize_tool_choice\nselect_tools_for_choice"] end A --> B C --> B B --> P["Tagged Prompt\n严格标签协议"] P --> M["纯文本大模型\n不支持 native function calling"] M --> X["非流式文本\n<think> / <tool_calls> / <final_answer>"] M --> Y["流式 chunk"] subgraph T2["text2tool"] D["parse_tagged_output\nparse_to_openai_assistant_turn"] E["TaggedStreamParser"] end X --> D Y --> E C --> D C --> E D --> R["OpenAI-style 输出\ncontent / tool_calls / finish_reason"] E --> R R --> O S["models.py\nOpenAI DTOs"] -.共享模型.

阅读全文