跳转到内容
搜索文档

API 参考

最后更新 查看 MarkdownAgent 设置

了解嵌入式 function calling 的 API 参考。

runWithTools

此包装方法使您能够进行嵌入式 function calling。您向其传递 AI 绑定、模型、输入(messages 数组和 tools 数组)以及可选配置。

  • AI BindingAi
    • AI 绑定,例如 env.AI
  • modelBaseAiTextGenerationModels
    • 支持 function calling 的模型 ID。例如 @hf/nousresearch/hermes-2-pro-mistral-7b
  • inputObject
    • messagesRoleScopedChatInput[]
    • toolsAiTextGenerationToolInputWithFunction[]
  • configObject
    • streamFinalResponseboolean optional
    • maxRecursiveToolRunsnumber optional
    • strictValidationboolean optional
    • verboseboolean optional
    • trimFunctionboolean optional - 对于 trimFunction,您可以传递 autoTrimTools,这是我们设计的另一个辅助方法,在发送推理之前自动选择正确的 tool(使用 LLM)。这意味着您的最终推理调用将拥有更少的输入 token。

createToolsFromOpenAPISpec

此方法允许您基于 OpenAPI spec 自动创建 tool schema,因此您无需手动编写或硬编码 tool schema。您可以传递 JSON 或 YAML 格式的任何 API 的 OpenAPI spec。

createToolsFromOpenAPISpec 具有 config 输入,允许您在需要提供 Authentication 或 User-Agent 等 header 时进行覆盖。

  • specstring
    • JSON 或 YAML 格式的 OpenAPI 规范,或远程 OpenAPI 规范的 URL。
  • configConfig optional - createToolsFromOpenAPISpec 函数的配置选项
    • overridesConfigRule[] optional
    • matchPatternsRegExp[] optional
    • options Object optional { verbose boolean optional }

这篇文档对您有帮助吗?