fix(utils.py): support deepseek tool calling

Fixes https://github.com/BerriAI/litellm/issues/5081
This commit is contained in:
Krrish Dholakia 2024-08-07 11:14:05 -07:00
parent 5dd4493a73
commit 788b06a33c
2 changed files with 29 additions and 18 deletions

View file

@ -4085,9 +4085,28 @@ async def test_acompletion_gemini():
def test_completion_deepseek():
litellm.set_verbose = True
model_name = "deepseek/deepseek-chat"
messages = [{"role": "user", "content": "Hey, how's it going?"}]
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"],
},
},
},
]
messages = [{"role": "user", "content": "How's the weather in Hangzhou?"}]
try:
response = completion(model=model_name, messages=messages)
response = completion(model=model_name, messages=messages, tools=tools)
# Add any assertions here to check the response
print(response)
except litellm.APIError as e: