Disambiguate invalid model name errors

because that error can be thrown in several different places, so
knowing the function it's being thrown from can be very useul for debugging.
This commit is contained in:
Marc Abramowitz 2024-04-30 14:34:54 -07:00
parent c1ffa7d409
commit 24ddba804f

View file

@ -3644,7 +3644,7 @@ async def chat_completion(
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
"error": "Invalid model name passed in model=" "error": "chat_completion: Invalid model name passed in model="
+ data.get("model", "") + data.get("model", "")
}, },
) )
@ -3833,7 +3833,7 @@ async def completion(
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
"error": "Invalid model name passed in model=" "error": "completion: Invalid model name passed in model="
+ data.get("model", "") + data.get("model", "")
}, },
) )
@ -4041,7 +4041,7 @@ async def embeddings(
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
"error": "Invalid model name passed in model=" "error": "embeddings: Invalid model name passed in model="
+ data.get("model", "") + data.get("model", "")
}, },
) )
@ -4197,7 +4197,7 @@ async def image_generation(
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
"error": "Invalid model name passed in model=" "error": "image_generation: Invalid model name passed in model="
+ data.get("model", "") + data.get("model", "")
}, },
) )
@ -4372,7 +4372,7 @@ async def audio_transcriptions(
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
"error": "Invalid model name passed in model=" "error": "audio_transcriptions: Invalid model name passed in model="
+ data.get("model", "") + data.get("model", "")
}, },
) )
@ -4538,7 +4538,7 @@ async def moderations(
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
detail={ detail={
"error": "Invalid model name passed in model=" "error": "moderations: Invalid model name passed in model="
+ data.get("model", "") + data.get("model", "")
}, },
) )