diff --git a/litellm/tests/test_configs/test_bad_config.yaml b/litellm/tests/test_configs/test_bad_config.yaml index bf059b10d0..9899af2b7a 100644 --- a/litellm/tests/test_configs/test_bad_config.yaml +++ b/litellm/tests/test_configs/test_bad_config.yaml @@ -7,4 +7,10 @@ model_list: litellm_params: model: azure/chatgpt-v-2 api_base: os.environ/AZURE_API_BASE - api_key: bad-key \ No newline at end of file + api_key: bad-key + - model_name: azure-embedding + litellm_params: + model: azure/azure-embedding-model + api_base: os.environ/AZURE_API_BASE + api_key: bad-key + \ No newline at end of file diff --git a/litellm/tests/test_proxy_exception_mapping.py b/litellm/tests/test_proxy_exception_mapping.py index 9824122e94..5dcb782c4a 100644 --- a/litellm/tests/test_proxy_exception_mapping.py +++ b/litellm/tests/test_proxy_exception_mapping.py @@ -47,6 +47,8 @@ def test_chat_completion_exception(client): except Exception as e: pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}") + +# raise openai.AuthenticationError def test_chat_completion_exception_azure(client): try: # Your test data @@ -72,6 +74,30 @@ def test_chat_completion_exception_azure(client): pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}") +# raise openai.AuthenticationError +def test_embedding_auth_exception_azure(client): + try: + # Your test data + test_data = { + "model": "azure-embedding", + "input": ["hi"] + } + + response = client.post("/embeddings", json=test_data) + print("Response from proxy=", response) + + # make an openai client to call _make_status_error_from_response + openai_client = openai.OpenAI(api_key="anything") + openai_exception = openai_client._make_status_error_from_response(response=response) + print("Exception raised=", openai_exception) + assert isinstance(openai_exception, openai.AuthenticationError) + + except Exception as e: + pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}") + + + + # raise openai.BadRequestError # chat/completions openai def test_exception_openai_bad_model(client):