本章介绍 OpenAI Function Calling,可以和 ReAct 框架设计的文章一起看。

可以理解为,ReAct 是 LLM Agent 的一种设计框架或范式,而 OpenAI Function Calling 是基于该设计范式的具体实现。

OpenAI 作为行业标杆,OpenAI Function Calling 的标准规范被很多同行共识。不仅仅是 ChatGPT,像 DeepSeek 等模型也遵循一样的标准。所以学习它,适用范围会很广。

1. 概述

1.1. 基本概念

OpenAI Function Calling(函数调用)是OpenAI在其GPT-3.5和GPT-4模型中推出的一项重要功能,允许开发者定义“函数”并让模型自动识别何时、如何调用这些函数,从而大大增强了大模型与外部工具、数据库、API等系统的集成能力。

OpenAI Function Calling 极大拓展了大模型的能力边界,让模型不再只是“聊天”,而可以作为智能的“中控大脑”,协调各种工具和服务,为用户提供更丰富、更准确、更有用的智能体验。

1)定义

Function Calling是一种让大语言模型不仅仅生成文本,还能结构化地调用外部函数(或API)的机制。开发者向模型描述可用的函数(包括名称、参数、参数类型、描述等),模型在理解用户输入后,自动决定是否需要调用这些函数,并返回结构化的调用请求(如JSON格式),开发者接收到请求后,实际执行函数并将结果返回给模型,模型再基于结果生成最终回复。

2)官方文档

1.2. 流程场景

1)工作流程
  1. 定义函数
    开发者通过OpenAI API的functions参数,提供函数的元数据(通常采用JSON Schema规范),描述每个函数的名称、参数、参数类型及说明。
  2. 用户提问
    用户向聊天机器人输入问题或指令。
  3. 模型判断
    模型根据上下文和函数描述,自动判断是否需要调用函数,以及用什么参数调用哪个函数。
  4. 结构化调用
    如果模型认为需要调用函数,会返回带有function_call字段的结构化响应,内容包括函数名和参数。
  5. 实际调用
    开发者用返回的信息实际调用后端函数或API,获取结果。
  6. 返回结果给模型
    开发者把函数执行结果(通常以字符串或JSON格式)通过API传回模型。
  7. 最终回复用户
    模型基于函数返回的结果,生成自然语言回复给用户。
2)典型应用场景
  • 智能助手调用日历、天气、数据库查询等API
  • 自动化表单填写、数据结构化提取
  • 企业知识库检索与问答(RAG)
  • 多工具协作(如搜索、计算、推荐等)

1.3. 简单示例

1)示例

假设你有一个查询天气的API:

1. 定义函数

{
  "name": "get_weather",
  "description": "获取指定城市的天气",
  "parameters": {
    "type": "object",
    "properties": {
      "city": {
        "type": "string",
        "description": "要查询天气的城市名称"
      }
    },
    "required": ["city"]
  }
}

2. 用户提问

帮我查一下北京的天气

3. 模型输出

{
  "function_call": {
    "name": "get_weather",
    "arguments": "{ \"city\": \"北京\" }"
  }
}

4. 实际调用API并返回结果

开发者调用get_weather("北京"),获得如"北京,晴,26℃"

5. 反馈给模型

将函数结果作为消息传递给模型。

6. 模型最终回复

北京现在是晴天,气温26℃。
2)技术细节
  • 函数描述采用JSON Schema,可以指定参数类型、必选参数、枚举值等,模型会根据描述自动填充参数。
  • 多函数支持,可同时定义多个函数,模型会判断哪个函数最适合当前请求。
  • 嵌套调用,支持一次对多个函数的连续调用(如多步推理)。
  • 与插件/工具整合,Function Calling是插件、RAG等更高级能力的基础。
3)注意事项
  • 安全性:模型生成的函数参数需验证,防止恶意输入。
  • 函数设计要清晰明了,描述详细,便于模型理解。
  • API响应需结构化、简明,利于模型处理和生成准确回复。
  • 不是代码生成,而是结构化的函数调用意图表达。

2. 多Tool 示例

ReAct 模式中,Planner(规划者) 制定好计划,可能会包含多个 Tool 的调用。

OpenAI Function Calling 机制中也一样。在同时给多个工具(函数)时,LLM 会根据用户的自然语言请求,自动判断并选择最合适的函数和参数进行调用。

  • 支持多工具/多函数注册,模型自动选择最合适的一个或多个。
  • 无需手动指定,只需描述好各个函数,模型会理解和判断。
  • 能极大提高智能体的自动化和灵活性

再看看具体示例:

1)多工具注册

你可以在 API 调用时通过 functions 参数,一次性注册多个函数(工具),每个函数都有自己的名称、参数和描述。模型会根据这些描述理解每个函数的用途。

示例:注册多个函数

[
  {
    "name": "get_weather",
    "description": "获取指定城市的天气",
    "parameters": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string",
          "description": "要查询天气的城市名称"
        }
      },
      "required": ["city"]
    }
  },
  {
    "name": "get_news",
    "description": "获取指定城市的最新新闻",
    "parameters": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string",
          "description": "要查询新闻的城市名称"
        }
      },
      "required": ["city"]
    }
  }
]
2)用户提问

用户输入一个请求,比如:

帮我查一下上海的新闻
3)模型自动选择合适的函数**

此时,模型会根据你的输入和函数描述,自动判断该调用哪个函数。

模型返回的结构化结果可能是:

{
  "function_call": {
    "name": "get_news",
    "arguments": "{ \"city\": \"上海\" }"
  }
}

如果你问:

上海今天什么天气?

模型会返回:

{
  "function_call": {
    "name": "get_weather",
    "arguments": "{ \"city\": \"上海\" }"
  }
}
4)多工具选择说明
  • 如果用户的请求只适合一个函数,模型会选择最合适的那个。
  • 如果用户的请求可以拆分为多个函数(如“查一下上海的天气和新闻”),模型可能会依次调用多个函数(取决于API调用配置和模型能力)。
  • 你可以通过function_call: "auto"让模型自动选择,也可以强制调用某个函数。

3. 多Tools(并行)示例

在 ReAct 模式中,Planner(规划者)可能同时提出多个工具(函数)调用;在 OpenAI Function Calling 中,模型也可以在同一条消息里返回多个工具调用,你可以在服务端并行执行这些调用并将结果逐一回传给模型。

  • 模型可在一条回复中返回多个工具调用(tool_calls)。
  • 并行执行由你端实现;模型仅“提出要调用哪些工具及其参数”。
  • 每个调用都有唯一的 id;回传结果时需用 tool_call_id 逐一绑定。
  • 并行能显著提升整体吞吐与响应速度(前提是工具之间无依赖)。

具体示例:

1)多工具注册(函数列表)

一次性注册多个函数(工具),模型会基于描述理解用途,并可能在同一轮中同时调用多个。

[
  {
    "name": "get_weather",
    "description": "获取指定城市当天的天气",
    "parameters": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string",
          "description": "要查询天气的城市名称"
        }
      },
      "required": ["city"]
    }
  },
  {
    "name": "get_news",
    "description": "获取指定城市的最新新闻列表",
    "parameters": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string",
          "description": "要查询新闻的城市名称"
        }
      },
      "required": ["city"]
    }
  }
]
2)用户提问
请同时告诉我上海今天的天气和最新新闻
3)模型一次返回多个工具调用(并行候选)

模型根据输入与函数描述,自动判断需要调用多个工具,并在一条消息中给出结构化的 tool_calls 数组:

{
  "tool_calls": [
    {
      "id": "call_1",
      "type": "function",
      "function": {
        "name": "get_weather",
        "arguments": "{ \"city\": \"上海\" }"
      }
    },
    {
      "id": "call_2",
      "type": "function",
      "function": {
        "name": "get_news",
        "arguments": "{ \"city\": \"上海\" }"
      }
    }
  ]
}
4)并行执行与结果回传(由你端实现)

你可以在服务端并发执行这两个函数,并将每个工具的输出与对应的 tool_call_id 绑定后回传给模型:

[
  {
    "role": "tool",
    "tool_call_id": "call_1",
    "content": "{ \"date\": \"2025-10-01\", \"temp\": 26, \"condition\": \"多云\", \"aqi\": 58 }"
  },
  {
    "role": "tool",
    "tool_call_id": "call_2",
    "content": "[ { \"title\": \"上海举办科技展\", \"link\": \"https://example.com/a\" }, { \"title\": \"浦东新消息\", \"link\": \"https://example.com/b\" } ]"
  }
]
5)模型综合回答

在收到两个工具结果后,模型会汇总并给出最终答案(示例):

上海今日多云,气温约 26℃,空气质量指数 58,属于良好。
最新新闻包括:
1) 上海举办科技展:https://example.com/a
2) 浦东新消息:https://example.com/b
并行说明与注意事项
  • 并行条件:工具之间无依赖即可并行;若 B 需要 A 的结果,请按依赖顺序串行执行。
  • 责任边界:模型只会给出多个调用请求;真正的并发执行、资源调度、超时与重试由你端负责。
  • 结果绑定:务必使用 tool_call_id 对号回传,各工具输出不可混淆。
  • 异常处理:设置每个工具的超时、重试与幂等;失败时可回传错误摘要让模型决定下一步。
  • 资源控制:可在提示中限定“最多并行 N 个工具”,或在服务端做并发限流。
  • 流式场景:tool_calls 信息可能增量到达;在拿到某个调用的完整 namearguments 后再启动执行。
  • 指令提示:可以在系统/开发者提示中明确要求“如需调用多个工具请在同一轮合并发起”,提升并行机会与效率。

4. API 规范

4.1. HTTP 请求参数

1)核心字段
参数名类型必填说明
modelstring指定模型名称(如 deepseek-reasoner)。
messagesarray对话历史消息列表(含 userassistanttool 角色)。
toolsarray定义可用的工具列表(如 MCP)。若省略,模型不会调用工具。
tool_choicestring控制工具调用行为(autonone 或指定工具名 {"name": "MCP"})。
2)messages 格式

每条消息需包含:

{
  "role": "user" | "assistant" | "tool",
  "content": "输入内容",
  "name": "工具名(仅 role=tool 时可选)",  // 如 "MCP"
  "tool_call_id": "工具调用ID(仅 role=tool 时必填)"
}

示例

"messages": [
  {"role": "user", "content": "查北京到上海的航班"},
  {"role": "assistant", "content": "", "tool_calls": [...]},  // 模型请求调用工具
  {"role": "tool", "name": "MCP", "content": "{...}", "tool_call_id": "call_123"}
]
3)tools 定义

每个工具需描述其名称、功能、输入参数:

"tools": [
  {
    "name": "MCP",
    "description": "多条件处理工具",
    "parameters": {
      "type": "object",
      "properties": {
        "query_type": {"type": "string", "enum": ["flight", "hotel"]},
        "max_price": {"type": "number"}
      },
      "required": ["query_type"]
    }
  }
]
  • parameters:遵循 JSON Schema 格式,定义工具的参数结构和校验规则。
4)tool_choice 选项
说明
"auto"模型自主决定是否调用工具(默认行为)。
"none"强制不调用工具,即使 tools 已定义。
{"name": "MCP"}强制调用指定工具(需与 tools 中的名称一致)。

4.2. HTTP 响应参数

1)核心字段
字段名类型说明
idstring本次调用的唯一ID。
choicesarray包含模型生成的结果(通常只有1个元素)。
usageobjectToken 使用统计(prompt_tokens, completion_tokens)。
2)choices[0].message 结构
字段名类型说明
rolestring固定为 "assistant"
contentstring模型的自然语言回复(若未调用工具,直接返回内容)。
tool_callsarray模型请求调用的工具列表(仅当 tool_choice 允许时返回)。
3)tool_calls 详细结构

每个工具调用包含:

{
  "id": "call_123",          // 工具调用唯一ID(用于后续匹配结果)
  "name": "MCP",             // 工具名称
  "parameters": {            // 模型生成的参数
    "query_type": "flight",
    "max_price": 5000
  }
}

5. 和 ReAct 的关系

5.1. 二者概述

1)OpenAI Function Calling 概述

OpenAI Function Calling 是OpenAI自2023年起在其API中推出的能力,允许开发者为大语言模型(如GPT-4/3.5)注册一系列结构化的“函数”或“工具”(以JSON Schema描述),模型可根据用户意图自动输出要调用的函数及参数,后端实际调用API/工具,并将结果反馈给模型用于最终回复。这一机制让模型能安全、标准化地与外部世界互动,极大拓展了LLM的应用边界。

主要特点:

  • 工具/函数注册标准化(JSON Schema)
  • LLM输出结构化调用意图(function_call)
  • 工具调用安全、可控,适合工程化集成
  • 支持多轮工具调用与组合
2)ReAct 概述

ReAct(Reason + Act)是普林斯顿大学等提出的一种大模型智能体推理与行动范式(2022年论文),其核心思想是让LLM通过自然语言显式地“思考”(Reason)和“行动”(Act),并根据工具反馈(Observation)进行多轮推理和行动,从而完成复杂任务。

主要特点:

  • 以自然语言串联“思考-行动-反思”链
  • LLM可以多步推理、动态决策、多工具协作
  • 适合复杂智能体(Agent)和研究探索
  • 工具调用通常需外部代理解析LLM的自然语言Action

5.2. 区别

1)定位不同
  • ReAct
    是一种大语言模型智能体推理与行动的理念/范式,强调 Reason(推理)、Act(行动)和 Observation(反馈)的循环,核心是让 LLM 多轮思考、用工具、反思再行动。这是一种“怎么设计智能体思路”的方法论,不是具体的接口或代码实现。
  • OpenAI Function Calling
    是一种具体的API/接口能力,让开发者可以把各种工具/函数以结构化的方式暴露给LLM,模型能直接用结构化格式(如JSON)发起工具调用。这是一个“怎么让模型安全、标准地用工具”的工程机制。
2)关系
  • Function Calling 可以用来实现 ReAct 范式的“行动”部分。
    在ReAct中,“Action”通常由模型输出自然语言(如 Action: Search[北京天气]),再由外部系统解析、执行。
  • 有了Function Calling,模型可以直接用结构化方式发起工具调用,极大提升了安全性和标准化
  • 现在很多智能体框架(如LangChain、ChatGPT Agents等)都把Function Calling作为底层接口,配合ReAct等范式,实现多步推理与工具协作。
3)类比举例
  • ReAct 就像是“做菜的方法/流程(先想吃什么、再去做、尝一口、再调整)”
  • Function Calling 就像是“厨房里的一套标准化厨具和操作台”
  • 你可以用Function Calling这套工具,去落地ReAct的做菜流程

5.3. 关系与融合

  • Function Calling不是ReAct的实现框架,但可以是ReAct智能体工程实现中的重要技术组件。
  • ReAct是理念/范式,Function Calling是工程化标准接口。
  • Function Calling可以作为ReAct智能体的底层工具调用接口,提升安全性与标准化
  • 二者关系是:ReAct定义了智能体行为范式,Function Calling提供了工程实现的基础能力

现代Agent系统常用ReAct范式组织推理链,用Function Calling做实际工具调用(如LangChain、ChatGPT Agents等)

二者可以结合:用ReAct组织推理、用Function Calling安全调用工具,打造强大智能体

6. 示例-CherryStudio

背景说明

Cherry Studio 作为接受度较高的大模型 Agent,在聊天时支持集成 MCP知识库

以 MCP 为例,可以同时勾选可使用的多个 MCP 工具集合。在对话时,大模型基于用户对话语义可以实现以下内容:

  • 从支持的 MCP 集合中,选择调用哪些 MCP 工具
  • 选择调用的 MCP 工具,也会有调用顺序,依次执行,收集结果后再次赋值上下文
  • 最终汇总 MCP 和 LLM 结果,以自然语言返回给用户

现在市场上不仅是 Cherry Studio,只要是支持集成 MCP 的大模型 Agent, 都要支持上述的工作模式。

看起来这就是 ReAct 范式,就看 Agent 是以什么方式去实现的了。是传统基于提示词多轮推理/行动的方式,还是基于 Function Calling 标准的实现。

目前来看,在使用 DeepSeek 作为聊天模型时,Cherry Studio 使用 OpenAI Function Calling 来实现。

下面看完整调用示例。
勾选了支持的2个MCP:12306-mcp(12306服务)amap-maps(高德地图服务)

image.png
image.png

6.1. LLM:推荐Tool(获取当前日期)

请求
{
    "model": "deepseek-chat",
    "messages": [
        {
            "role": "system",
            "content": "\n\n## Using the think tool\n\nBefore taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to:\n- List the specific rules that apply to the current request\n- Check if all required information is collected\n- Verify that the planned action complies with all policies\n- Iterate over tool results for correctness \n- Response in user query language\n\nHere are some examples of what to iterate over inside the think tool:\n<think_tool_example_1>\nUser wants to cancel flight ABC123\n- Need to verify: user ID, reservation ID, reason\n- Check cancellation rules:\n  * Is it within 24h of booking?\n  * If not, check ticket class and insurance\n- Verify no segments flown or are in the past\n- Plan: collect missing info, verify rules, get confirmation\n</think_tool_example_1>\n\n<think_tool_example_2>\nUser wants to book 3 tickets to NYC with 2 checked bags each\n- Need user ID to check:\n  * Membership tier for baggage allowance\n  * Which payments methods exist in profile\n- Baggage calculation:\n  * Economy class × 3 passengers\n  * If regular member: 1 free bag each → 3 extra bags = $150\n  * If silver member: 2 free bags each → 0 extra bags = $0\n  * If gold member: 3 free bags each → 0 extra bags = $0\n- Payment rules to verify:\n  * Max 1 travel certificate, 1 credit card, 3 gift cards\n  * All payment methods must be in profile\n  * Travel certificate remainder goes to waste\n- Plan:\n1. Get user ID\n2. Verify membership level for bag fees\n3. Check which payment methods in profile and if their combination is allowed\n4. Calculate total: ticket price + any bag fees\n5. Get explicit confirmation for booking\n</think_tool_example_2>\n"
        },
        {
            "role": "user",
            "content": "今天下午从苏州到北京的高铁票还有没"
        }
    ],
    "temperature": 0,
    "top_p": 1,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_current_date",
                "description": "获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 \"yyyy-MM-dd\"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。",
                "parameters": {
                    "type": "object",
                    "properties": {

                    }
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_stations_code_in_city",
                "description": "通过中文城市名查询该城市 **所有** 火车站的名称及其对应的 `station_code`,结果是一个包含多个车站信息的列表。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "中文城市名称,例如:\"北京\", \"上海\""
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_of_citys",
                "description": "通过中文城市名查询代表该城市的 `station_code`。此接口主要用于在用户提供**城市名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "citys": {
                            "type": "string",
                            "description": "要查询的城市,比如\"北京\"。若要查询多个城市,请用|分割,比如\"北京|上海\"。"
                        }
                    },
                    "required": [
                        "citys"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_by_names",
                "description": "通过具体的中文车站名查询其 `station_code` 和车站名。此接口主要用于在用户提供**具体车站名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationNames": {
                            "type": "string",
                            "description": "具体的中文车站名称,例如:\"北京南\", \"上海虹桥\"。若要查询多个站点,请用|分割,比如\"北京南|上海虹桥\"。"
                        }
                    },
                    "required": [
                        "stationNames"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_by_telecode",
                "description": "通过车站的 `station_telecode` 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 `telecode` 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationTelecode": {
                            "type": "string",
                            "description": "车站的 `station_telecode` (3位字母编码)"
                        }
                    },
                    "required": [
                        "stationTelecode"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_tickets",
                "description": "查询12306余票信息。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "到达地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空,即不筛选。支持多个标志同时筛选。例如用户说“高铁票”,则应使用 \"G\"。可选标志:[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 0,
                            "default": 0,
                            "description": "返回的余票数量限制,默认为0,即不限制。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_interline_tickets",
                "description": "查询12306中转余票信息。尚且只支持查询前十条。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "middleStation": {
                            "type": "string",
                            "default": "",
                            "description": "中转地的 `station_code` ,可选。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "showWZ": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否显示无座车,默认不显示无座车。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 1,
                            "default": 10,
                            "description": "返回的中转余票数量限制,默认为10。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_train_route_stations",
                "description": "查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "trainNo": {
                            "type": "string",
                            "description": "要查询的实际车次编号 `train_no`,例如 \"240000G10336\",而非\"G1033\"。此编号通常可以从 `get-tickets` 的查询结果中获取,或者由用户直接提供。"
                        },
                        "fromStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**出发站**的 `station_telecode` (3位字母编码`)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "toStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**到达站**的 `station_telecode` (3位字母编码)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "departDate": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "列车从 `fromStationTelecode` 指定的车站出发的日期 (格式: yyyy-MM-dd)。如果用户提供的是相对日期,请务必先调用 `get-current-date` 解析。"
                        }
                    },
                    "required": [
                        "trainNo",
                        "fromStationTelecode",
                        "toStationTelecode",
                        "departDate"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_regeocode",
                "description": "将一个高德经纬度坐标转换为行政区划地址信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "经纬度"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_geo",
                "description": "将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string",
                            "description": "待解析的结构化地址信息"
                        },
                        "city": {
                            "type": "string",
                            "description": "指定查询的城市"
                        }
                    },
                    "required": [
                        "address"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_ip_location",
                "description": "IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "ip": {
                            "type": "string",
                            "description": "IP地址"
                        }
                    },
                    "required": [
                        "ip"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_weather",
                "description": "根据城市名称或者标准adcode查询指定城市的天气",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "城市名称或者adcode"
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_search_detail",
                "description": "查询关键词搜或者周边搜获取到的POI ID的详细信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "string",
                            "description": "关键词搜或者周边搜获取到的POI ID"
                        }
                    },
                    "required": [
                        "id"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_bicycling",
                "description": "骑行路径规划用于规划骑行通勤方案,规划时会考虑天桥、单行线、封路等情况。最大支持 500km 的骑行路线规划",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_walking",
                "description": "步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_driving",
                "description": "驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_transit_integrated",
                "description": "公交路径规划 API 可以根据用户起终点经纬度坐标规划综合各类公共(火车、公交、地铁)交通方式的通勤方案,并且返回通勤方案的数据,跨城场景下必须传起点城市与终点城市",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        },
                        "city": {
                            "type": "string",
                            "description": "公共交通规划起点城市"
                        },
                        "cityd": {
                            "type": "string",
                            "description": "公共交通规划终点城市"
                        }
                    },
                    "required": [
                        "origin",
                        "destination",
                        "city",
                        "cityd"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_distance",
                "description": "距离测量 API 可以测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origins": {
                            "type": "string",
                            "description": "起点经度,纬度,可以传多个坐标,使用竖线隔离,比如120,30|120,31,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "终点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "type": {
                            "type": "string",
                            "description": "距离测量类型,1代表驾车距离测量,0代表直线距离测量,3步行距离测量"
                        }
                    },
                    "required": [
                        "origins",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_text_search",
                "description": "关键词搜,根据用户传入关键词,搜索出相关的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "city": {
                            "type": "string",
                            "description": "查询城市"
                        },
                        "types": {
                            "type": "string",
                            "description": "POI类型,比如加油站"
                        }
                    },
                    "required": [
                        "keywords"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_around_search",
                "description": "周边搜,根据用户传入关键词以及坐标location,搜索出radius半径范围的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "location": {
                            "type": "string",
                            "description": "中心点经度纬度"
                        },
                        "radius": {
                            "type": "string",
                            "description": "搜索半径"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "dummy-server-think",
                "description": "Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. For example, if you explore the repo and discover the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective. Alternatively, if you receive some test results, call this tool to brainstorm ways to fix the failing tests.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "thought": {
                            "type": "string",
                            "description": "Your thoughts."
                        }
                    },
                    "required": [
                        "thought"
                    ]
                }
            }
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    }
}
响应
{
  "id": "7e797a77-ffeb-447f-bdf2-ebd3564a0280",
  "object": "chat.completion",
  "created": 1754027442,
  "model": "deepseek-chat",
  "system_fingerprint": "fp_8802369eaa_prod0623_fp8_kvcache",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "",
        "tool_calls": [
          {
            "id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
            "type": "function",
            "function": {
              "name": "tool-12306_m-get_current_date",
              "arguments": "{}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 4993,
    "completion_tokens": 20,
    "total_tokens": 5013,
    "prompt_tokens_details": {
      "cached_tokens": 4992
    },
    "prompt_cache_hit_tokens": 4992,
    "prompt_cache_miss_tokens": 1
  }
}

6.2. Tool:调用 get-current-date

12306-mcp : get-current-date
{
  "params": {},
  "response": {
    "content": [
      {
        "type": "text",
        "text": "2025-08-01"
      }
    ],
    "isError": false
  }
}

6.3. LLM:推荐Tool(获取车站)

请求
{
    "model": "deepseek-chat",
    "messages": [
        {
            "role": "system",
            "content": "\n\n## Using the think tool\n\nBefore taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to:\n- List the specific rules that apply to the current request\n- Check if all required information is collected\n- Verify that the planned action complies with all policies\n- Iterate over tool results for correctness \n- Response in user query language\n\nHere are some examples of what to iterate over inside the think tool:\n<think_tool_example_1>\nUser wants to cancel flight ABC123\n- Need to verify: user ID, reservation ID, reason\n- Check cancellation rules:\n  * Is it within 24h of booking?\n  * If not, check ticket class and insurance\n- Verify no segments flown or are in the past\n- Plan: collect missing info, verify rules, get confirmation\n</think_tool_example_1>\n\n<think_tool_example_2>\nUser wants to book 3 tickets to NYC with 2 checked bags each\n- Need user ID to check:\n  * Membership tier for baggage allowance\n  * Which payments methods exist in profile\n- Baggage calculation:\n  * Economy class × 3 passengers\n  * If regular member: 1 free bag each → 3 extra bags = $150\n  * If silver member: 2 free bags each → 0 extra bags = $0\n  * If gold member: 3 free bags each → 0 extra bags = $0\n- Payment rules to verify:\n  * Max 1 travel certificate, 1 credit card, 3 gift cards\n  * All payment methods must be in profile\n  * Travel certificate remainder goes to waste\n- Plan:\n1. Get user ID\n2. Verify membership level for bag fees\n3. Check which payment methods in profile and if their combination is allowed\n4. Calculate total: ticket price + any bag fees\n5. Get explicit confirmation for booking\n</think_tool_example_2>\n"
        },
        {
            "role": "user",
            "content": "今天下午从苏州到北京的高铁票还有没"
        },
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
                    "function": {
                        "name": "tool-12306_m-get_current_date",
                        "arguments": "{}"
                    },
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
            "content": "[{\"type\":\"text\",\"text\":\"2025-08-01\"}]"
        }
    ],
    "temperature": 0,
    "top_p": 1,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_current_date",
                "description": "获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 \"yyyy-MM-dd\"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。",
                "parameters": {
                    "type": "object",
                    "properties": {

                    }
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_stations_code_in_city",
                "description": "通过中文城市名查询该城市 **所有** 火车站的名称及其对应的 `station_code`,结果是一个包含多个车站信息的列表。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "中文城市名称,例如:\"北京\", \"上海\""
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_of_citys",
                "description": "通过中文城市名查询代表该城市的 `station_code`。此接口主要用于在用户提供**城市名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "citys": {
                            "type": "string",
                            "description": "要查询的城市,比如\"北京\"。若要查询多个城市,请用|分割,比如\"北京|上海\"。"
                        }
                    },
                    "required": [
                        "citys"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_by_names",
                "description": "通过具体的中文车站名查询其 `station_code` 和车站名。此接口主要用于在用户提供**具体车站名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationNames": {
                            "type": "string",
                            "description": "具体的中文车站名称,例如:\"北京南\", \"上海虹桥\"。若要查询多个站点,请用|分割,比如\"北京南|上海虹桥\"。"
                        }
                    },
                    "required": [
                        "stationNames"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_by_telecode",
                "description": "通过车站的 `station_telecode` 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 `telecode` 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationTelecode": {
                            "type": "string",
                            "description": "车站的 `station_telecode` (3位字母编码)"
                        }
                    },
                    "required": [
                        "stationTelecode"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_tickets",
                "description": "查询12306余票信息。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "到达地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空,即不筛选。支持多个标志同时筛选。例如用户说“高铁票”,则应使用 \"G\"。可选标志:[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 0,
                            "default": 0,
                            "description": "返回的余票数量限制,默认为0,即不限制。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_interline_tickets",
                "description": "查询12306中转余票信息。尚且只支持查询前十条。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "middleStation": {
                            "type": "string",
                            "default": "",
                            "description": "中转地的 `station_code` ,可选。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "showWZ": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否显示无座车,默认不显示无座车。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 1,
                            "default": 10,
                            "description": "返回的中转余票数量限制,默认为10。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_train_route_stations",
                "description": "查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "trainNo": {
                            "type": "string",
                            "description": "要查询的实际车次编号 `train_no`,例如 \"240000G10336\",而非\"G1033\"。此编号通常可以从 `get-tickets` 的查询结果中获取,或者由用户直接提供。"
                        },
                        "fromStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**出发站**的 `station_telecode` (3位字母编码`)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "toStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**到达站**的 `station_telecode` (3位字母编码)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "departDate": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "列车从 `fromStationTelecode` 指定的车站出发的日期 (格式: yyyy-MM-dd)。如果用户提供的是相对日期,请务必先调用 `get-current-date` 解析。"
                        }
                    },
                    "required": [
                        "trainNo",
                        "fromStationTelecode",
                        "toStationTelecode",
                        "departDate"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_regeocode",
                "description": "将一个高德经纬度坐标转换为行政区划地址信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "经纬度"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_geo",
                "description": "将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string",
                            "description": "待解析的结构化地址信息"
                        },
                        "city": {
                            "type": "string",
                            "description": "指定查询的城市"
                        }
                    },
                    "required": [
                        "address"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_ip_location",
                "description": "IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "ip": {
                            "type": "string",
                            "description": "IP地址"
                        }
                    },
                    "required": [
                        "ip"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_weather",
                "description": "根据城市名称或者标准adcode查询指定城市的天气",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "城市名称或者adcode"
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_search_detail",
                "description": "查询关键词搜或者周边搜获取到的POI ID的详细信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "string",
                            "description": "关键词搜或者周边搜获取到的POI ID"
                        }
                    },
                    "required": [
                        "id"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_bicycling",
                "description": "骑行路径规划用于规划骑行通勤方案,规划时会考虑天桥、单行线、封路等情况。最大支持 500km 的骑行路线规划",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_walking",
                "description": "步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_driving",
                "description": "驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_transit_integrated",
                "description": "公交路径规划 API 可以根据用户起终点经纬度坐标规划综合各类公共(火车、公交、地铁)交通方式的通勤方案,并且返回通勤方案的数据,跨城场景下必须传起点城市与终点城市",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        },
                        "city": {
                            "type": "string",
                            "description": "公共交通规划起点城市"
                        },
                        "cityd": {
                            "type": "string",
                            "description": "公共交通规划终点城市"
                        }
                    },
                    "required": [
                        "origin",
                        "destination",
                        "city",
                        "cityd"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_distance",
                "description": "距离测量 API 可以测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origins": {
                            "type": "string",
                            "description": "起点经度,纬度,可以传多个坐标,使用竖线隔离,比如120,30|120,31,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "终点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "type": {
                            "type": "string",
                            "description": "距离测量类型,1代表驾车距离测量,0代表直线距离测量,3步行距离测量"
                        }
                    },
                    "required": [
                        "origins",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_text_search",
                "description": "关键词搜,根据用户传入关键词,搜索出相关的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "city": {
                            "type": "string",
                            "description": "查询城市"
                        },
                        "types": {
                            "type": "string",
                            "description": "POI类型,比如加油站"
                        }
                    },
                    "required": [
                        "keywords"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_around_search",
                "description": "周边搜,根据用户传入关键词以及坐标location,搜索出radius半径范围的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "location": {
                            "type": "string",
                            "description": "中心点经度纬度"
                        },
                        "radius": {
                            "type": "string",
                            "description": "搜索半径"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "dummy-server-think",
                "description": "Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. For example, if you explore the repo and discover the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective. Alternatively, if you receive some test results, call this tool to brainstorm ways to fix the failing tests.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "thought": {
                            "type": "string",
                            "description": "Your thoughts."
                        }
                    },
                    "required": [
                        "thought"
                    ]
                }
            }
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    }
}
响应
{
  "id": "376160df-ae9b-412a-8aa2-611b7d34f755",
  "object": "chat.completion",
  "created": 1754027448,
  "model": "deepseek-chat",
  "system_fingerprint": "fp_8802369eaa_prod0623_fp8_kvcache",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "",
        "tool_calls": [
          {
            "id": "call_0_dc1f5222-7e15-44c4-9aa8-f93114074ce9",
            "type": "function",
            "function": {
              "name": "tool-12306_m-get_station_code_of_citys",
              "arguments": "{\"citys\": \"苏州|北京\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 5034,
    "completion_tokens": 33,
    "total_tokens": 5067,
    "prompt_tokens_details": {
      "cached_tokens": 4992
    },
    "prompt_cache_hit_tokens": 4992,
    "prompt_cache_miss_tokens": 42
  }
}

6.4. Tool:调用 get-station-code-of-citys

12306-mcp : get-station-code-of-citys
{
  "params": {
    "citys": "苏州|北京"
  },
  "response": {
    "content": [
      {
        "type": "text",
        "text": "{\"苏州\":{\"station_code\":\"SZH\",\"station_name\":\"苏州\"},\"北京\":{\"station_code\":\"BJP\",\"station_name\":\"北京\"}}"
      }
    ],
    "isError": false
  }
}

6.5. LLM:推荐Tool(查询车票)

请求
{
    "model": "deepseek-chat",
    "messages": [
        {
            "role": "system",
            "content": "\n\n## Using the think tool\n\nBefore taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to:\n- List the specific rules that apply to the current request\n- Check if all required information is collected\n- Verify that the planned action complies with all policies\n- Iterate over tool results for correctness \n- Response in user query language\n\nHere are some examples of what to iterate over inside the think tool:\n<think_tool_example_1>\nUser wants to cancel flight ABC123\n- Need to verify: user ID, reservation ID, reason\n- Check cancellation rules:\n  * Is it within 24h of booking?\n  * If not, check ticket class and insurance\n- Verify no segments flown or are in the past\n- Plan: collect missing info, verify rules, get confirmation\n</think_tool_example_1>\n\n<think_tool_example_2>\nUser wants to book 3 tickets to NYC with 2 checked bags each\n- Need user ID to check:\n  * Membership tier for baggage allowance\n  * Which payments methods exist in profile\n- Baggage calculation:\n  * Economy class × 3 passengers\n  * If regular member: 1 free bag each → 3 extra bags = $150\n  * If silver member: 2 free bags each → 0 extra bags = $0\n  * If gold member: 3 free bags each → 0 extra bags = $0\n- Payment rules to verify:\n  * Max 1 travel certificate, 1 credit card, 3 gift cards\n  * All payment methods must be in profile\n  * Travel certificate remainder goes to waste\n- Plan:\n1. Get user ID\n2. Verify membership level for bag fees\n3. Check which payment methods in profile and if their combination is allowed\n4. Calculate total: ticket price + any bag fees\n5. Get explicit confirmation for booking\n</think_tool_example_2>\n"
        },
        {
            "role": "user",
            "content": "今天下午从苏州到北京的高铁票还有没"
        },
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
                    "function": {
                        "name": "tool-12306_m-get_current_date",
                        "arguments": "{}"
                    },
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
            "content": "[{\"type\":\"text\",\"text\":\"2025-08-01\"}]"
        },
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_0_dc1f5222-7e15-44c4-9aa8-f93114074ce9",
                    "function": {
                        "name": "tool-12306_m-get_station_code_of_citys",
                        "arguments": "{\"citys\": \"苏州|北京\"}"
                    },
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_0_dc1f5222-7e15-44c4-9aa8-f93114074ce9",
            "content": "[{\"type\":\"text\",\"text\":\"{\\\"苏州\\\":{\\\"station_code\\\":\\\"SZH\\\",\\\"station_name\\\":\\\"苏州\\\"},\\\"北京\\\":{\\\"station_code\\\":\\\"BJP\\\",\\\"station_name\\\":\\\"北京\\\"}}\"}]"
        }
    ],
    "temperature": 0,
    "top_p": 1,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_current_date",
                "description": "获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 \"yyyy-MM-dd\"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。",
                "parameters": {
                    "type": "object",
                    "properties": {

                    }
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_stations_code_in_city",
                "description": "通过中文城市名查询该城市 **所有** 火车站的名称及其对应的 `station_code`,结果是一个包含多个车站信息的列表。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "中文城市名称,例如:\"北京\", \"上海\""
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_of_citys",
                "description": "通过中文城市名查询代表该城市的 `station_code`。此接口主要用于在用户提供**城市名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "citys": {
                            "type": "string",
                            "description": "要查询的城市,比如\"北京\"。若要查询多个城市,请用|分割,比如\"北京|上海\"。"
                        }
                    },
                    "required": [
                        "citys"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_by_names",
                "description": "通过具体的中文车站名查询其 `station_code` 和车站名。此接口主要用于在用户提供**具体车站名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationNames": {
                            "type": "string",
                            "description": "具体的中文车站名称,例如:\"北京南\", \"上海虹桥\"。若要查询多个站点,请用|分割,比如\"北京南|上海虹桥\"。"
                        }
                    },
                    "required": [
                        "stationNames"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_by_telecode",
                "description": "通过车站的 `station_telecode` 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 `telecode` 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationTelecode": {
                            "type": "string",
                            "description": "车站的 `station_telecode` (3位字母编码)"
                        }
                    },
                    "required": [
                        "stationTelecode"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_tickets",
                "description": "查询12306余票信息。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "到达地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空,即不筛选。支持多个标志同时筛选。例如用户说“高铁票”,则应使用 \"G\"。可选标志:[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 0,
                            "default": 0,
                            "description": "返回的余票数量限制,默认为0,即不限制。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_interline_tickets",
                "description": "查询12306中转余票信息。尚且只支持查询前十条。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "middleStation": {
                            "type": "string",
                            "default": "",
                            "description": "中转地的 `station_code` ,可选。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "showWZ": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否显示无座车,默认不显示无座车。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 1,
                            "default": 10,
                            "description": "返回的中转余票数量限制,默认为10。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_train_route_stations",
                "description": "查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "trainNo": {
                            "type": "string",
                            "description": "要查询的实际车次编号 `train_no`,例如 \"240000G10336\",而非\"G1033\"。此编号通常可以从 `get-tickets` 的查询结果中获取,或者由用户直接提供。"
                        },
                        "fromStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**出发站**的 `station_telecode` (3位字母编码`)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "toStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**到达站**的 `station_telecode` (3位字母编码)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "departDate": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "列车从 `fromStationTelecode` 指定的车站出发的日期 (格式: yyyy-MM-dd)。如果用户提供的是相对日期,请务必先调用 `get-current-date` 解析。"
                        }
                    },
                    "required": [
                        "trainNo",
                        "fromStationTelecode",
                        "toStationTelecode",
                        "departDate"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_regeocode",
                "description": "将一个高德经纬度坐标转换为行政区划地址信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "经纬度"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_geo",
                "description": "将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string",
                            "description": "待解析的结构化地址信息"
                        },
                        "city": {
                            "type": "string",
                            "description": "指定查询的城市"
                        }
                    },
                    "required": [
                        "address"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_ip_location",
                "description": "IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "ip": {
                            "type": "string",
                            "description": "IP地址"
                        }
                    },
                    "required": [
                        "ip"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_weather",
                "description": "根据城市名称或者标准adcode查询指定城市的天气",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "城市名称或者adcode"
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_search_detail",
                "description": "查询关键词搜或者周边搜获取到的POI ID的详细信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "string",
                            "description": "关键词搜或者周边搜获取到的POI ID"
                        }
                    },
                    "required": [
                        "id"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_bicycling",
                "description": "骑行路径规划用于规划骑行通勤方案,规划时会考虑天桥、单行线、封路等情况。最大支持 500km 的骑行路线规划",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_walking",
                "description": "步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_driving",
                "description": "驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_transit_integrated",
                "description": "公交路径规划 API 可以根据用户起终点经纬度坐标规划综合各类公共(火车、公交、地铁)交通方式的通勤方案,并且返回通勤方案的数据,跨城场景下必须传起点城市与终点城市",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        },
                        "city": {
                            "type": "string",
                            "description": "公共交通规划起点城市"
                        },
                        "cityd": {
                            "type": "string",
                            "description": "公共交通规划终点城市"
                        }
                    },
                    "required": [
                        "origin",
                        "destination",
                        "city",
                        "cityd"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_distance",
                "description": "距离测量 API 可以测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origins": {
                            "type": "string",
                            "description": "起点经度,纬度,可以传多个坐标,使用竖线隔离,比如120,30|120,31,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "终点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "type": {
                            "type": "string",
                            "description": "距离测量类型,1代表驾车距离测量,0代表直线距离测量,3步行距离测量"
                        }
                    },
                    "required": [
                        "origins",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_text_search",
                "description": "关键词搜,根据用户传入关键词,搜索出相关的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "city": {
                            "type": "string",
                            "description": "查询城市"
                        },
                        "types": {
                            "type": "string",
                            "description": "POI类型,比如加油站"
                        }
                    },
                    "required": [
                        "keywords"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_around_search",
                "description": "周边搜,根据用户传入关键词以及坐标location,搜索出radius半径范围的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "location": {
                            "type": "string",
                            "description": "中心点经度纬度"
                        },
                        "radius": {
                            "type": "string",
                            "description": "搜索半径"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "dummy-server-think",
                "description": "Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. For example, if you explore the repo and discover the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective. Alternatively, if you receive some test results, call this tool to brainstorm ways to fix the failing tests.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "thought": {
                            "type": "string",
                            "description": "Your thoughts."
                        }
                    },
                    "required": [
                        "thought"
                    ]
                }
            }
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    }
}
响应
{
  "id": "5407396f-3ca3-4b02-85cc-c22f0b6995a6",
  "object": "chat.completion",
  "created": 1754027455,
  "model": "deepseek-chat",
  "system_fingerprint": "fp_8802369eaa_prod0623_fp8_kvcache",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_0_1c8b7022-0954-497d-832a-9e13939dd228",
            "type": "function",
            "function": {
              "name": "tool-12306_m-get_tickets",
              "arguments": "{\"date\":\"2025-08-01\",\"fromStation\":\"SZH\",\"toStation\":\"BJP\",\"trainFilterFlags\":\"G\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 5122,
    "completion_tokens": 47,
    "total_tokens": 5169,
    "prompt_tokens_details": {
      "cached_tokens": 5120
    },
    "prompt_cache_hit_tokens": 5120,
    "prompt_cache_miss_tokens": 2
  }
}

6.6. Tool:调用 get-tickets

12306-mcp : get-tickets
{
  "params": {
    "date": "2025-08-01",
    "fromStation": "SZH",
    "toStation": "BJP",
    "trainFilterFlags": "G"
  },
  "response": {
    "content": [
      {
        "type": "text",
        "text": "车次 | 出发站 -> 到达站 | 出发时间 -> 到达时间 | 历时\nG142(实际车次train_no: 5l0000G14204) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 14:47 -> 20:10 历时:05:23\n- 商务座: 剩余2张票 2194元\n- 一等座: 无票 1003元\n- 二等座: 无票 627元\n- 无座: 无票 627元\nG2590(实际车次train_no: 56000G259002) 盛泽(telecode: SJU) -> 北京南(telecode: VNP) 15:02 -> 23:29 历时:08:27\n- 商务座: 剩余3张票 1953元\n- 一等座: 无票 1011元\n- 二等座: 无票 619元\n- 无座: 无票 619元\nG2590(实际车次train_no: 56000G259002) 苏州南(telecode: SMU) -> 北京南(telecode: VNP) 15:16 -> 23:29 历时:08:13\n- 商务座: 剩余3张票 1901元\n- 一等座: 无票 988元\n- 二等座: 无票 604元\n- 无座: 无票 604元\nG150(实际车次train_no: 5l0000G15073) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 16:29 -> 21:56 历时:05:27\n- 商务座: 剩余10张票 2194元\n- 一等座: 无票 1003元\n- 二等座: 无票 627元\n- 无座: 有票 627元\nG24(实际车次train_no: 5l00000G2411) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 17:23 -> 21:33 历时:04:10\n- 商务座: 剩余1张票 2194元\n- 一等座: 无票 1003元\n- 二等座: 无票 627元\n- 优选一等座: 无票 1379元\n- 无座: 剩余3张票 627元\nG156(实际车次train_no: 5l0000G15606) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 17:41 -> 23:08 历时:05:27\n- 商务座: 有票 2194元\n- 一等座: 有票 1003元\n- 二等座: 无票 627元\n- 无座: 有票 627元\nG158(实际车次train_no: 560000G15801) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 17:45 -> 23:14 历时:05:29\n- 商务座: 剩余18张票 2194元\n- 一等座: 有票 1003元\n- 二等座: 无票 627元\n- 无座: 剩余13张票 627元\nG160(实际车次train_no: 5l0000G16008) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 18:06 -> 23:42 历时:05:36\n- 商务座: 剩余12张票 1891元\n- 一等座: 剩余13张票 917元\n- 二等座: 无票 545元\n- 无座: 有票 545元\nG162(实际车次train_no: 5l0000G16203) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 18:11 -> 23:51 历时:05:40\n- 商务座: 剩余12张票 2043元\n- 一等座: 剩余8张票 952元\n- 二等座: 无票 567元\n- 无座: 有票 567元\nG28(实际车次train_no: 5l00000G2802) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 19:15 -> 23:18 历时:04:03\n- 商务座: 无票 2194元\n- 一等座: 无票 1003元\n- 二等座: 无票 627元\n- 优选一等座: 无票 1379元\n- 无座: 无票 627元\n"
      }
    ],
    "isError": false
  }
}

6.7. LLM:总结输出结果

请求
{
    "model": "deepseek-chat",
    "messages": [
        {
            "role": "system",
            "content": "\n\n## Using the think tool\n\nBefore taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to:\n- List the specific rules that apply to the current request\n- Check if all required information is collected\n- Verify that the planned action complies with all policies\n- Iterate over tool results for correctness \n- Response in user query language\n\nHere are some examples of what to iterate over inside the think tool:\n<think_tool_example_1>\nUser wants to cancel flight ABC123\n- Need to verify: user ID, reservation ID, reason\n- Check cancellation rules:\n  * Is it within 24h of booking?\n  * If not, check ticket class and insurance\n- Verify no segments flown or are in the past\n- Plan: collect missing info, verify rules, get confirmation\n</think_tool_example_1>\n\n<think_tool_example_2>\nUser wants to book 3 tickets to NYC with 2 checked bags each\n- Need user ID to check:\n  * Membership tier for baggage allowance\n  * Which payments methods exist in profile\n- Baggage calculation:\n  * Economy class × 3 passengers\n  * If regular member: 1 free bag each → 3 extra bags = $150\n  * If silver member: 2 free bags each → 0 extra bags = $0\n  * If gold member: 3 free bags each → 0 extra bags = $0\n- Payment rules to verify:\n  * Max 1 travel certificate, 1 credit card, 3 gift cards\n  * All payment methods must be in profile\n  * Travel certificate remainder goes to waste\n- Plan:\n1. Get user ID\n2. Verify membership level for bag fees\n3. Check which payment methods in profile and if their combination is allowed\n4. Calculate total: ticket price + any bag fees\n5. Get explicit confirmation for booking\n</think_tool_example_2>\n"
        },
        {
            "role": "user",
            "content": "今天下午从苏州到北京的高铁票还有没"
        },
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
                    "function": {
                        "name": "tool-12306_m-get_current_date",
                        "arguments": "{}"
                    },
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_0_5f2f5b7a-de13-4551-a7e6-97cd10e3639d",
            "content": "[{\"type\":\"text\",\"text\":\"2025-08-01\"}]"
        },
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_0_dc1f5222-7e15-44c4-9aa8-f93114074ce9",
                    "function": {
                        "name": "tool-12306_m-get_station_code_of_citys",
                        "arguments": "{\"citys\": \"苏州|北京\"}"
                    },
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_0_dc1f5222-7e15-44c4-9aa8-f93114074ce9",
            "content": "[{\"type\":\"text\",\"text\":\"{\\\"苏州\\\":{\\\"station_code\\\":\\\"SZH\\\",\\\"station_name\\\":\\\"苏州\\\"},\\\"北京\\\":{\\\"station_code\\\":\\\"BJP\\\",\\\"station_name\\\":\\\"北京\\\"}}\"}]"
        },
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": "call_0_1c8b7022-0954-497d-832a-9e13939dd228",
                    "function": {
                        "name": "tool-12306_m-get_tickets",
                        "arguments": "{\"date\":\"2025-08-01\",\"fromStation\":\"SZH\",\"toStation\":\"BJP\",\"trainFilterFlags\":\"G\"}"
                    },
                    "type": "function"
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_0_1c8b7022-0954-497d-832a-9e13939dd228",
            "content": "[{\"type\":\"text\",\"text\":\"车次 | 出发站 -> 到达站 | 出发时间 -> 到达时间 | 历时\\nG142(实际车次train_no: 5l0000G14204) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 14:47 -> 20:10 历时:05:23\\n- 商务座: 剩余2张票 2194元\\n- 一等座: 无票 1003元\\n- 二等座: 无票 627元\\n- 无座: 无票 627元\\nG2590(实际车次train_no: 56000G259002) 盛泽(telecode: SJU) -> 北京南(telecode: VNP) 15:02 -> 23:29 历时:08:27\\n- 商务座: 剩余3张票 1953元\\n- 一等座: 无票 1011元\\n- 二等座: 无票 619元\\n- 无座: 无票 619元\\nG2590(实际车次train_no: 56000G259002) 苏州南(telecode: SMU) -> 北京南(telecode: VNP) 15:16 -> 23:29 历时:08:13\\n- 商务座: 剩余3张票 1901元\\n- 一等座: 无票 988元\\n- 二等座: 无票 604元\\n- 无座: 无票 604元\\nG150(实际车次train_no: 5l0000G15073) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 16:29 -> 21:56 历时:05:27\\n- 商务座: 剩余10张票 2194元\\n- 一等座: 无票 1003元\\n- 二等座: 无票 627元\\n- 无座: 有票 627元\\nG24(实际车次train_no: 5l00000G2411) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 17:23 -> 21:33 历时:04:10\\n- 商务座: 剩余1张票 2194元\\n- 一等座: 无票 1003元\\n- 二等座: 无票 627元\\n- 优选一等座: 无票 1379元\\n- 无座: 剩余3张票 627元\\nG156(实际车次train_no: 5l0000G15606) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 17:41 -> 23:08 历时:05:27\\n- 商务座: 有票 2194元\\n- 一等座: 有票 1003元\\n- 二等座: 无票 627元\\n- 无座: 有票 627元\\nG158(实际车次train_no: 560000G15801) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 17:45 -> 23:14 历时:05:29\\n- 商务座: 剩余18张票 2194元\\n- 一等座: 有票 1003元\\n- 二等座: 无票 627元\\n- 无座: 剩余13张票 627元\\nG160(实际车次train_no: 5l0000G16008) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 18:06 -> 23:42 历时:05:36\\n- 商务座: 剩余12张票 1891元\\n- 一等座: 剩余13张票 917元\\n- 二等座: 无票 545元\\n- 无座: 有票 545元\\nG162(实际车次train_no: 5l0000G16203) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 18:11 -> 23:51 历时:05:40\\n- 商务座: 剩余12张票 2043元\\n- 一等座: 剩余8张票 952元\\n- 二等座: 无票 567元\\n- 无座: 有票 567元\\nG28(实际车次train_no: 5l00000G2802) 苏州北(telecode: OHH) -> 北京南(telecode: VNP) 19:15 -> 23:18 历时:04:03\\n- 商务座: 无票 2194元\\n- 一等座: 无票 1003元\\n- 二等座: 无票 627元\\n- 优选一等座: 无票 1379元\\n- 无座: 无票 627元\\n\"}]"
        }
    ],
    "temperature": 0,
    "top_p": 1,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_current_date",
                "description": "获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 \"yyyy-MM-dd\"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),为其他需要日期的接口提供准确的日期输入。",
                "parameters": {
                    "type": "object",
                    "properties": {

                    }
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_stations_code_in_city",
                "description": "通过中文城市名查询该城市 **所有** 火车站的名称及其对应的 `station_code`,结果是一个包含多个车站信息的列表。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "中文城市名称,例如:\"北京\", \"上海\""
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_of_citys",
                "description": "通过中文城市名查询代表该城市的 `station_code`。此接口主要用于在用户提供**城市名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "citys": {
                            "type": "string",
                            "description": "要查询的城市,比如\"北京\"。若要查询多个城市,请用|分割,比如\"北京|上海\"。"
                        }
                    },
                    "required": [
                        "citys"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_code_by_names",
                "description": "通过具体的中文车站名查询其 `station_code` 和车站名。此接口主要用于在用户提供**具体车站名**作为出发地或到达地时,为接口准备 `station_code` 参数。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationNames": {
                            "type": "string",
                            "description": "具体的中文车站名称,例如:\"北京南\", \"上海虹桥\"。若要查询多个站点,请用|分割,比如\"北京南|上海虹桥\"。"
                        }
                    },
                    "required": [
                        "stationNames"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_station_by_telecode",
                "description": "通过车站的 `station_telecode` 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 `telecode` 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "stationTelecode": {
                            "type": "string",
                            "description": "车站的 `station_telecode` (3位字母编码)"
                        }
                    },
                    "required": [
                        "stationTelecode"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_tickets",
                "description": "查询12306余票信息。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "到达地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空,即不筛选。支持多个标志同时筛选。例如用户说“高铁票”,则应使用 \"G\"。可选标志:[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 0,
                            "default": 0,
                            "description": "返回的余票数量限制,默认为0,即不限制。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_interline_tickets",
                "description": "查询12306中转余票信息。尚且只支持查询前十条。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "date": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"
                        },
                        "fromStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "toStation": {
                            "type": "string",
                            "description": "出发地的 `station_code` 。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "middleStation": {
                            "type": "string",
                            "default": "",
                            "description": "中转地的 `station_code` ,可选。必须是通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到的编码,严禁直接使用中文地名。"
                        },
                        "showWZ": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否显示无座车,默认不显示无座车。"
                        },
                        "trainFilterFlags": {
                            "type": "string",
                            "pattern": "^[GDZTKOFS]*$",
                            "maxLength": 8,
                            "default": "",
                            "description": "车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"
                        },
                        "sortFlag": {
                            "type": "string",
                            "default": "",
                            "description": "排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"
                        },
                        "sortReverse": {
                            "type": "boolean",
                            "default": false,
                            "description": "是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"
                        },
                        "limitedNum": {
                            "type": "number",
                            "minimum": 1,
                            "default": 10,
                            "description": "返回的中转余票数量限制,默认为10。"
                        }
                    },
                    "required": [
                        "date",
                        "fromStation",
                        "toStation"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "tool-12306_m-get_train_route_stations",
                "description": "查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "trainNo": {
                            "type": "string",
                            "description": "要查询的实际车次编号 `train_no`,例如 \"240000G10336\",而非\"G1033\"。此编号通常可以从 `get-tickets` 的查询结果中获取,或者由用户直接提供。"
                        },
                        "fromStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**出发站**的 `station_telecode` (3位字母编码`)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "toStationTelecode": {
                            "type": "string",
                            "description": "该列车行程的**到达站**的 `station_telecode` (3位字母编码)。通常来自 `get-tickets` 结果中的 `telecode` 字段,或者通过 `get-station-code-by-names` 得到。"
                        },
                        "departDate": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 10,
                            "description": "列车从 `fromStationTelecode` 指定的车站出发的日期 (格式: yyyy-MM-dd)。如果用户提供的是相对日期,请务必先调用 `get-current-date` 解析。"
                        }
                    },
                    "required": [
                        "trainNo",
                        "fromStationTelecode",
                        "toStationTelecode",
                        "departDate"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_regeocode",
                "description": "将一个高德经纬度坐标转换为行政区划地址信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "经纬度"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_geo",
                "description": "将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string",
                            "description": "待解析的结构化地址信息"
                        },
                        "city": {
                            "type": "string",
                            "description": "指定查询的城市"
                        }
                    },
                    "required": [
                        "address"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_ip_location",
                "description": "IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "ip": {
                            "type": "string",
                            "description": "IP地址"
                        }
                    },
                    "required": [
                        "ip"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_weather",
                "description": "根据城市名称或者标准adcode查询指定城市的天气",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {
                            "type": "string",
                            "description": "城市名称或者adcode"
                        }
                    },
                    "required": [
                        "city"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_search_detail",
                "description": "查询关键词搜或者周边搜获取到的POI ID的详细信息",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "string",
                            "description": "关键词搜或者周边搜获取到的POI ID"
                        }
                    },
                    "required": [
                        "id"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_bicycling",
                "description": "骑行路径规划用于规划骑行通勤方案,规划时会考虑天桥、单行线、封路等情况。最大支持 500km 的骑行路线规划",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_walking",
                "description": "步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_driving",
                "description": "驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        }
                    },
                    "required": [
                        "origin",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_direction_transit_integrated",
                "description": "公交路径规划 API 可以根据用户起终点经纬度坐标规划综合各类公共(火车、公交、地铁)交通方式的通勤方案,并且返回通勤方案的数据,跨城场景下必须传起点城市与终点城市",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origin": {
                            "type": "string",
                            "description": "出发点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "目的地经度,纬度,坐标格式为:经度,纬度"
                        },
                        "city": {
                            "type": "string",
                            "description": "公共交通规划起点城市"
                        },
                        "cityd": {
                            "type": "string",
                            "description": "公共交通规划终点城市"
                        }
                    },
                    "required": [
                        "origin",
                        "destination",
                        "city",
                        "cityd"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_distance",
                "description": "距离测量 API 可以测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "origins": {
                            "type": "string",
                            "description": "起点经度,纬度,可以传多个坐标,使用竖线隔离,比如120,30|120,31,坐标格式为:经度,纬度"
                        },
                        "destination": {
                            "type": "string",
                            "description": "终点经度,纬度,坐标格式为:经度,纬度"
                        },
                        "type": {
                            "type": "string",
                            "description": "距离测量类型,1代表驾车距离测量,0代表直线距离测量,3步行距离测量"
                        }
                    },
                    "required": [
                        "origins",
                        "destination"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_text_search",
                "description": "关键词搜,根据用户传入关键词,搜索出相关的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "city": {
                            "type": "string",
                            "description": "查询城市"
                        },
                        "types": {
                            "type": "string",
                            "description": "POI类型,比如加油站"
                        }
                    },
                    "required": [
                        "keywords"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "amap_ma-maps_around_search",
                "description": "周边搜,根据用户传入关键词以及坐标location,搜索出radius半径范围的POI",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "keywords": {
                            "type": "string",
                            "description": "搜索关键词"
                        },
                        "location": {
                            "type": "string",
                            "description": "中心点经度纬度"
                        },
                        "radius": {
                            "type": "string",
                            "description": "搜索半径"
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        },
        {
            "type": "function",
            "function": {
                "name": "dummy-server-think",
                "description": "Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. For example, if you explore the repo and discover the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective. Alternatively, if you receive some test results, call this tool to brainstorm ways to fix the failing tests.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "thought": {
                            "type": "string",
                            "description": "Your thoughts."
                        }
                    },
                    "required": [
                        "thought"
                    ]
                }
            }
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    }
}
响应
{
  "id": "6b1ac405-d8e4-43bc-9c3d-a1d55921b479",
  "object": "chat.completion",
  "created": 1754027462,
  "model": "deepseek-chat",
  "system_fingerprint": "fp_8802369eaa_prod0623_fp8_kvcache",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "今天下午从苏州到北京的高铁票有以下选择:\n\n1. **G142次**  \n   - 出发站:苏州北 (14:47)  \n   - 到达站:北京南 (20:10)  \n   - 历时:05:23  \n   - 余票:商务座2张(2194元),其他座位无票。\n\n2. **G150次**  \n   - 出发站:苏州北 (16:29)  \n   - 到达站:北京南 (21:56)  \n   - 历时:05:27  \n   - 余票:商务座10张(2194元),无座票有票(627元)。\n\n3. **G24次**  \n   - 出发站:苏州北 (17:23)  \n   - 到达站:北京南 (22:50)  \n   - 历时:05:27  \n   - 余票:商务座充足 北京南 (21:33)  \n   - 历时:04:10  \n   - 余票:商务座1张(2194元),无座票3张(627元)。\n\n4. **G156次**  \n   - 出发站:苏州北 (17:41)  \n   - 到达站:北京南 (23:08)  \n   - 历时:05:27  \n   - 余票:商务座有票(2194元),一等座有票(1003元),无座票有票(627元)。\n\n5. **G158次**  \n   - 出发站:苏州北 (17:45)  \n   - 到达站:北京南 (23:14)  \n   - 历时:05:29  \n   - 余票:商务座18张(2194元),一等座有票(1003元),无座票13张(627元)。\n\n6. **G160次**  \n   - 出发站:苏州北 (18:06)  \n   - 到达站:北京南 (23:42)  \n   - 历时:05:36  \n   - 余票:商务座12张(1891元),一等座13张(917元),无座票有票(545元)。\n\n7. **G162次**  \n   - 出发站:苏州北 (18:11)  \n   - 到达站:北京南 (23:51)  \n   - 历时:05:40  \n   - 余票:商务座12张(2043元),一等座8张(952元),无座票有票(567元)。\n\n如果需要预订或了解更多信息,请告诉我!"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6301,
    "completion_tokens": 534,
    "total_tokens": 6835,
    "prompt_tokens_details": {
      "cached_tokens": 5312
    },
    "prompt_cache_hit_tokens": 5312,
    "prompt_cache_miss_tokens": 989
  }
}

系统提示词

在第一次请求LLM时,Cherry Studio 内置了系统提示词。

提示词模板

## Using the think tool

Before taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to:
- List the specific rules that apply to the current request
- Check if all required information is collected
- Verify that the planned action complies with all policies
- Iterate over tool results for correctness 
- Response in user query language

Here are some examples of what to iterate over inside the think tool:
<think_tool_example_1>
User wants to cancel flight ABC123
- Need to verify: user ID, reservation ID, reason
- Check cancellation rules:
  * Is it within 24h of booking?
  * If not, check ticket class and insurance
- Verify no segments flown or are in the past
- Plan: collect missing info, verify rules, get confirmation
</think_tool_example_1>

<think_tool_example_2>
User wants to book 3 tickets to NYC with 2 checked bags each
- Need user ID to check:
  * Membership tier for baggage allowance
  * Which payments methods exist in profile
- Baggage calculation:
  * Economy class × 3 passengers
  * If regular member: 1 free bag each → 3 extra bags = $150
  * If silver member: 2 free bags each → 0 extra bags = $0
  * If gold member: 3 free bags each → 0 extra bags = $0
- Payment rules to verify:
  * Max 1 travel certificate, 1 credit card, 3 gift cards
  * All payment methods must be in profile
  * Travel certificate remainder goes to waste
- Plan:
1. Get user ID
2. Verify membership level for bag fees
3. Check which payment methods in profile and if their combination is allowed
4. Calculate total: ticket price + any bag fees
5. Get explicit confirmation for booking
</think_tool_example_2>
翻译中文后

## 使用思考工具

在采取任何行动或根据工具结果回复用户之前,请使用思考工具作为草稿纸来:

- 列出适用于当前请求的具体规则
- 检查是否已收集所有必要信息
- 验证计划行动是否符合所有政策
- 反复检查工具结果的正确性
- 使用用户查询语言进行回复

以下是思考工具内应反复检查的示例:

<思考工具示例1>
用户想取消航班ABC123

- 需要验证:用户ID、预订ID、取消原因
- 检查取消规则:
  * 是否在预订后24小时内?
  * 如果不是,检查机票舱位和保险情况
- 确认没有已飞行或过去的航段
- 计划:收集缺失信息,验证规则,获取确认
  </思考工具示例1>

<思考工具示例2>
用户想预订3张前往纽约的机票,每人2件托运行李

- 需要用户ID来检查:
  * 会员等级对应的行李额度
  * 个人资料中存在的支付方式
- 行李费用计算:
  * 经济舱×3位乘客
  * 普通会员:每人1件免费→需额外3件=$150
  * 银卡会员:每人2件免费→无需额外费用=$0
  * 金卡会员:每人3件免费→无需额外费用=$0
- 需验证的支付规则:
  * 最多1张旅行券、1张信用卡、3张礼品卡
  * 所有支付方式必须已在个人资料中
  * 旅行券剩余金额将作废
- 计划:

1. 获取用户ID
2. 根据会员等级确认行李费用
3. 检查个人资料中的支付方式及其组合是否被允许
4. 计算总费用:机票价格+行李费用
5. 获取明确的预订确认
   </思考工具示例2>

KerryWu
679 声望171 粉丝

保持饥饿