forked from phoenix/litellm-mirror
fix(utils.py): fix mistral api tool calling response
This commit is contained in:
parent
4acdde988f
commit
ab24f61099
3 changed files with 20 additions and 0 deletions
|
@ -650,6 +650,7 @@
|
|||
"input_cost_per_token": 0.000002,
|
||||
"output_cost_per_token": 0.000006,
|
||||
"litellm_provider": "mistral",
|
||||
"supports_function_calling": true,
|
||||
"mode": "chat"
|
||||
},
|
||||
"mistral/mistral-small-latest": {
|
||||
|
@ -659,6 +660,7 @@
|
|||
"input_cost_per_token": 0.000002,
|
||||
"output_cost_per_token": 0.000006,
|
||||
"litellm_provider": "mistral",
|
||||
"supports_function_calling": true,
|
||||
"mode": "chat"
|
||||
},
|
||||
"mistral/mistral-medium": {
|
||||
|
|
|
@ -10000,6 +10000,22 @@ class CustomStreamWrapper:
|
|||
t.function.arguments = ""
|
||||
_json_delta = delta.model_dump()
|
||||
print_verbose(f"_json_delta: {_json_delta}")
|
||||
if "role" not in _json_delta or _json_delta["role"] is None:
|
||||
_json_delta["role"] = (
|
||||
"assistant" # mistral's api returns role as None
|
||||
)
|
||||
if "tool_calls" in _json_delta and isinstance(
|
||||
_json_delta["tool_calls"], list
|
||||
):
|
||||
for tool in _json_delta["tool_calls"]:
|
||||
if (
|
||||
isinstance(tool, dict)
|
||||
and "function" in tool
|
||||
and isinstance(tool["function"], dict)
|
||||
and ("type" not in tool or tool["type"] is None)
|
||||
):
|
||||
# if function returned but type set to None - mistral's api returns type: None
|
||||
tool["type"] = "function"
|
||||
model_response.choices[0].delta = Delta(**_json_delta)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -650,6 +650,7 @@
|
|||
"input_cost_per_token": 0.000002,
|
||||
"output_cost_per_token": 0.000006,
|
||||
"litellm_provider": "mistral",
|
||||
"supports_function_calling": true,
|
||||
"mode": "chat"
|
||||
},
|
||||
"mistral/mistral-small-latest": {
|
||||
|
@ -659,6 +660,7 @@
|
|||
"input_cost_per_token": 0.000002,
|
||||
"output_cost_per_token": 0.000006,
|
||||
"litellm_provider": "mistral",
|
||||
"supports_function_calling": true,
|
||||
"mode": "chat"
|
||||
},
|
||||
"mistral/mistral-medium": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue