From a198d4a39fd6c386a4c755c212a7f3b4efa4e6e0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 2 Jul 2025 20:35:49 -0700 Subject: [PATCH] test: change mistral model service tier exceeded --- litellm/proxy/_new_secret_config.yaml | 12 ++++++++ tests/local_testing/test_completion.py | 41 +++++++++++++++----------- tests/local_testing/test_streaming.py | 5 ++-- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml index ca129503bc0..6ad4c778888 100644 --- a/litellm/proxy/_new_secret_config.yaml +++ b/litellm/proxy/_new_secret_config.yaml @@ -3,7 +3,19 @@ model_list: litellm_params: model: "gpt-4o" api_key: os.environ/OPENAI_API_KEY +<<<<<<< HEAD - model_name: "gemini-2.0-flash" +======= + +guardrails: + - guardrail_name: azure-prompt-shield + litellm_params: + guardrail: azure/prompt_shield + mode: pre_call # "During_call" is also available + api_key: os.environ/AZURE_GUARDRAIL_API_KEY + api_base: os.environ/AZURE_GUARDRAIL_API_BASE + - guardrail_name: azure-text-moderation +>>>>>>> 6ebc8d473 (test: change mistral model) litellm_params: model: "gemini/gemini-2.0-flash" api_key: os.environ/GEMINI_API_KEY diff --git a/tests/local_testing/test_completion.py b/tests/local_testing/test_completion.py index ee2245376b9..c97cd14cc21 100644 --- a/tests/local_testing/test_completion.py +++ b/tests/local_testing/test_completion.py @@ -131,6 +131,7 @@ def test_null_role_response(): assert response.choices[0].message.role == "assistant" + @pytest.mark.skip(reason="Cohere having RBAC issues") def test_completion_azure_command_r(): try: @@ -175,7 +176,6 @@ def test_completion_azure_ai_gpt_4o(api_base): pytest.fail(f"Error occurred: {e}") - def predibase_mock_post(url, data=None, json=None, headers=None, timeout=None): mock_response = MagicMock() mock_response.status_code = 200 @@ -905,7 +905,7 @@ def test_completion_mistral_api_mistral_large_function_call(): try: # test without max tokens response = completion( - model="mistral/open-mistral-7b", + model="mistral/mistral-medium-latest", messages=messages, tools=tools, tool_choice="auto", @@ -1475,7 +1475,6 @@ HF Tests we should pass """ - @pytest.mark.parametrize( "provider", ["openai", "hosted_vllm", "lm_studio", "llamafile"] ) # "vertex_ai", @@ -1560,6 +1559,7 @@ async def test_openai_compatible_custom_api_video(provider): mock_call.assert_called_once() + def test_lm_studio_completion(monkeypatch): monkeypatch.delenv("LM_STUDIO_API_KEY", raising=False) monkeypatch.delenv("OPENAI_API_KEY", raising=False) @@ -1578,6 +1578,7 @@ def test_lm_studio_completion(monkeypatch): except litellm.APIError as e: print(e) + # ################### Hugging Face Conversational models ######################## # def hf_test_completion_conv(): # try: @@ -1625,7 +1626,6 @@ def mock_post(url, **kwargs): return mock_response - def test_ollama_image(): """ Test that datauri prefixes are removed, JPEG/PNG images are passed @@ -4394,6 +4394,7 @@ def test_humanloop_completion(monkeypatch): messages=[{"role": "user", "content": "Tell me a joke."}], ) + def test_completion_novita_ai(): litellm.set_verbose = True messages = [ @@ -4403,10 +4404,11 @@ def test_completion_novita_ai(): "content": "Hey", }, ] - + from openai import OpenAI + openai_client = OpenAI(api_key="fake-key") - + with patch.object( openai_client.chat.completions, "create", new=MagicMock() ) as mock_call: @@ -4417,21 +4419,22 @@ def test_completion_novita_ai(): client=openai_client, api_base="https://api.novita.ai/v3/openai", ) - + mock_call.assert_called_once() - + # Verify model is passed correctly - assert mock_call.call_args.kwargs["model"] == "meta-llama/llama-3.3-70b-instruct" + assert ( + mock_call.call_args.kwargs["model"] + == "meta-llama/llama-3.3-70b-instruct" + ) # Verify messages are passed correctly assert mock_call.call_args.kwargs["messages"] == messages - + except Exception as e: pytest.fail(f"Error occurred: {e}") -@pytest.mark.parametrize( - "api_key", ["my-bad-api-key"] -) +@pytest.mark.parametrize("api_key", ["my-bad-api-key"]) def test_completion_novita_ai_dynamic_params(api_key): try: litellm.set_verbose = True @@ -4442,12 +4445,15 @@ def test_completion_novita_ai_dynamic_params(api_key): "content": "Hey", }, ] - + from openai import OpenAI + openai_client = OpenAI(api_key="fake-key") - + with patch.object( - openai_client.chat.completions, "create", side_effect=Exception("Invalid API key") + openai_client.chat.completions, + "create", + side_effect=Exception("Invalid API key"), ) as mock_call: try: completion( @@ -4461,11 +4467,12 @@ def test_completion_novita_ai_dynamic_params(api_key): except Exception as e: # This should fail with the mocked exception assert "Invalid API key" in str(e) - + mock_call.assert_called_once() except Exception as e: pytest.fail(f"Unexpected error: {e}") + def test_deepseek_reasoning_content_completion(): try: litellm.set_verbose = True diff --git a/tests/local_testing/test_streaming.py b/tests/local_testing/test_streaming.py index 8112357e0f2..bcb375d38a3 100644 --- a/tests/local_testing/test_streaming.py +++ b/tests/local_testing/test_streaming.py @@ -952,7 +952,7 @@ def test_completion_mistral_api_mistral_large_function_call_with_streaming(): try: # test without max tokens response = completion( - model="mistral/mistral-large-latest", + model="mistral/mistral-medium-latest", messages=messages, tools=tools, tool_choice="auto", @@ -2892,6 +2892,7 @@ def test_azure_streaming_and_function_calling(): pytest.fail(f"Error occurred: {e}") raise e + @pytest.mark.asyncio async def test_azure_astreaming_and_function_calling(): import uuid @@ -4022,4 +4023,4 @@ def test_is_delta_empty(): tool_calls=None, audio=None, ) - ) \ No newline at end of file + )