服务端启用(vLLM 示意)
服务端启用(vLLM 示意)
vllm serve <模型路径> --enable-auto-tool-choice --tool-call-parser hermes
# 解析器名称按模型族与版本文档选择请求侧
请求侧
tools = [{"type": "function", "function": {
"name": "get_weather",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
}}]
r = client.chat.completions.create(model="<模型名>", messages=[{"role": "user", "content": "上海天气?"}], tools=tools, tool_choice="auto")
print(r.choices[0].message.tool_calls)