胜算云Router文档
胜算云Router
胜算云Router
    • 快速入门
    • Quick start
    • 模型路由
    • model routing
    • 联网搜索
    • Online search
    • 工具和函数调用
    • Tool and function calling
    • 常见问题
    • 错误处理
    • 使用条款
    • 隐私政策
    • 付费充值协议
    • cherry studio和chat box配置指南
    • 数据安全协议和分析
    • MCP安装
    • Roo code配置
    • 胜算云Router开放平台服务协议
    • MCP installing
    • 如何在KiloSSY中使用胜算云Router
    • API文档
      • API 错误代码说明
      • 聊天补全
        POST
      • 文本向量化
        POST
      • 多模态向量化
        POST
      • 图像生成
        POST
      • 文本分词
        POST
      • 文本重排序
        POST

    Tool and function calling

    Tool Calling#

    Tool calling enables large language models (LLMs) to access external tools. The model doesn't directly execute these tools; it first recommends tools to invoke. The user then independently calls the tool externally and returns the result to the model. Finally, the model integrates the result to generate a response to the user's original query. Shengsuan Cloud Router standardizes this tool-calling interface across all models and providers.
    ToolCall Structure
    Represents tool invocation details when an LLM needs to call external functions/plugins during generation:
    Index: Call sequence in chat streams (optional)
    ID: Unique identifier for the tool call
    Type: Distinguishes between different tool-calling logic
    Function: Described by FunctionCall with function details

    Function Calling#

    When using text (chat) models via API, you can define functions for the model to optionally call. The model then outputs a JSON object containing necessary parameters. The text model API does not execute functions—it only outputs JSON that you can use to call functions in your own code.
    While modern models can autonomously determine when to call functions and generate JSON matching function signatures, this carries inherent risks. We strongly recommend implementing user confirmation steps before executing real-world actions (e.g., sending emails, online publishing, purchases).
    FunctionCall Structure
    Describes called function details:
    Description: Explains the call's purpose
    Name: Identifies the specific interface
    Parameters: Description of required arguments (typically JSON)
    Arguments: Actual parameter string passed to the function

    Common Use Cases#

    Function calling reliably extracts structured data from models. Examples include:
    1.
    Building API-connected assistants
    Example functions:
    send_email(to: string, body: string)
    get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')
    2.
    Converting natural language to API calls
    Example conversion:
    "Who are my top customers?" → get_customers(min_revenue: int, created_before: string, limit: int)
    Follow with internal API call
    3.
    Extracting structured data from text
    Example functions:
    extract_data(name: string, birthday: string)
    sql_query(query: string)

    Basic Function Calling Workflow#

    1.
    Call the model
    Send user query + define available functions in functions parameter
    2.
    Model responds
    Model may choose to call ≥1 functions. If calling:
    Outputs JSON matching your schema
    ⚠️ Models may hallucinate parameters
    3.
    Parse & execute
    Parse JSON string in your code
    Call functions using provided arguments
    4.
    Resubmit to model
    Append function results as new messages
    Let model summarize results for user

    Note: Shengsuan Router normalizes variations in function-calling implementations across different model providers.
    修改于 2025-05-29 05:39:21
    上一页
    工具和函数调用
    下一页
    常见问题
    Built with