Table of Contents
相关文档
-
deepseek funciton call: https://api-docs.deepseek.com/zh-cn/guides/function_calling#%E6%A0%B7%E4%BE%8B%E4%BB%A3%E7%A0%81
-
多轮对话补全: https://api-docs.deepseek.com/zh-cn/api/create-chat-completion
测试案例:
工具代码:
def get_weather(location:str):
"""
Get weather of an location, the user shoud supply a location first
Args:
location (str): The city and state, e.g. San Francisco, CA
"""
return {
"location": location,
"temperature": "72°F",
"conditions": "Sunny",
"humidity": "45%"
}
调用代码:
curl --location 'https://api.deepseek.com/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--header 'Cookie: HWWAFSESID=cfd4676c29d4334314; HWWAFSESTIME=1755770600735' \
--data '{
"model": "deepseek-chat",
"messages": [
{"role": "user", "content": "天津今天天气怎么样"},
{
"role": "assistant",
"content": "我来帮您查询天津今天的天气情况。",
"tool_calls": [
{
"index": 0,
"id": "call_0_6d8666ea-44a0-4833-b4b1-9504572e5ae0",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"天津\"}"
}
}
]
},
{"role": "tool", "tool_call_id": "call_0_6d8666ea-44a0-4833-b4b1-9504572e5ae0", "content": "天津 今天晴天 30度"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather of an location, the user shoud supply a location first",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
}
]
}'
大家一起来讨论