mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
(test) proxy - AuthError Exception mapping
This commit is contained in:
parent
a52c984b3f
commit
88dbedf2d8
2 changed files with 33 additions and 1 deletions
|
@ -7,4 +7,10 @@ model_list:
|
||||||
litellm_params:
|
litellm_params:
|
||||||
model: azure/chatgpt-v-2
|
model: azure/chatgpt-v-2
|
||||||
api_base: os.environ/AZURE_API_BASE
|
api_base: os.environ/AZURE_API_BASE
|
||||||
api_key: bad-key
|
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
|
||||||
|
|
|
@ -47,6 +47,8 @@ def test_chat_completion_exception(client):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||||
|
|
||||||
|
# raise openai.AuthenticationError
|
||||||
def test_chat_completion_exception_azure(client):
|
def test_chat_completion_exception_azure(client):
|
||||||
try:
|
try:
|
||||||
# Your test data
|
# Your test data
|
||||||
|
@ -72,6 +74,30 @@ def test_chat_completion_exception_azure(client):
|
||||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
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
|
# raise openai.BadRequestError
|
||||||
# chat/completions openai
|
# chat/completions openai
|
||||||
def test_exception_openai_bad_model(client):
|
def test_exception_openai_bad_model(client):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue