diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 98cdbde92..4f0111e76 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -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": { diff --git a/litellm/utils.py b/litellm/utils.py index 2d0b5cc96..cb8eb52e1 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -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() diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 98cdbde92..4f0111e76 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -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": {