Merge pull request #3142 from BerriAI/litellm_slack_alerting_show_model_passed

[Fix] Show `model` passed on `"400: {'error': 'Invalid model name passed in mode` errors 👻
This commit is contained in:
Ishaan Jaff
2024-04-18 16:18:17 -07:00
committed by GitHub
2 changed files with 28 additions and 7 deletions
+24 -6
View File
@@ -3417,7 +3417,10 @@ async def completion(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Invalid model name passed in"},
detail={
"error": "Invalid model name passed in model="
+ data.get("model", "")
},
)
if hasattr(response, "_hidden_params"):
@@ -3648,7 +3651,10 @@ async def chat_completion(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Invalid model name passed in"},
detail={
"error": "Invalid model name passed in model="
+ data.get("model", "")
},
)
# wait for call to end
@@ -3872,7 +3878,10 @@ async def embeddings(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Invalid model name passed in"},
detail={
"error": "Invalid model name passed in model="
+ data.get("model", "")
},
)
### ALERTING ###
@@ -4021,7 +4030,10 @@ async def image_generation(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Invalid model name passed in"},
detail={
"error": "Invalid model name passed in model="
+ data.get("model", "")
},
)
### ALERTING ###
@@ -4181,7 +4193,10 @@ async def audio_transcriptions(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Invalid model name passed in"},
detail={
"error": "Invalid model name passed in model="
+ data.get("model", "")
},
)
except Exception as e:
@@ -4340,7 +4355,10 @@ async def moderations(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Invalid model name passed in"},
detail={
"error": "Invalid model name passed in model="
+ data.get("model", "")
},
)
### ALERTING ###
@@ -167,8 +167,9 @@ def test_chat_completion_exception_any_model(client):
openai_exception = openai_client._make_status_error_from_response(
response=response
)
print("Exception raised=", openai_exception)
assert isinstance(openai_exception, openai.BadRequestError)
_error_message = openai_exception.message
assert "Invalid model name passed in model=Lite-GPT-12" in str(_error_message)
except Exception as e:
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
@@ -195,6 +196,8 @@ def test_embedding_exception_any_model(client):
)
print("Exception raised=", openai_exception)
assert isinstance(openai_exception, openai.BadRequestError)
_error_message = openai_exception.message
assert "Invalid model name passed in model=Lite-GPT-12" in str(_error_message)
except Exception as e:
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")