mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(feat) proxy: embeddings-add OpenAI exception mapping
This commit is contained in:
parent
d797bb100f
commit
0b4f1dee42
2 changed files with 40 additions and 4 deletions
|
@ -73,12 +73,12 @@ def test_chat_completion_exception_azure(client):
|
|||
|
||||
|
||||
# raise openai.BadRequestError
|
||||
|
||||
# chat/completions openai
|
||||
def test_exception_openai_bad_model(client):
|
||||
try:
|
||||
# Your test data
|
||||
test_data = {
|
||||
"model": "openai/GPT-12",
|
||||
"model": "azure/GPT-12",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
|
@ -99,7 +99,7 @@ def test_exception_openai_bad_model(client):
|
|||
except Exception as e:
|
||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||
|
||||
|
||||
# chat/completions any model
|
||||
def test_chat_completion_exception_any_model(client):
|
||||
try:
|
||||
# Your test data
|
||||
|
@ -125,3 +125,27 @@ def test_chat_completion_exception_any_model(client):
|
|||
except Exception as e:
|
||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||
|
||||
|
||||
|
||||
# embeddings any model
|
||||
def test_embedding_exception_any_model(client):
|
||||
try:
|
||||
# Your test data
|
||||
test_data = {
|
||||
"model": "Lite-GPT-12",
|
||||
"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.NotFoundError)
|
||||
|
||||
except Exception as e:
|
||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue