fix(bedrock_httpx.py): raise bad request error if invalid bedrock model given

This commit is contained in:
Krrish Dholakia 2024-08-13 19:26:22 -07:00
parent b8e5b25dcc
commit 66d77f177f
2 changed files with 17 additions and 3 deletions

View file

@ -1054,10 +1054,11 @@ class BedrockLLM(BaseLLM):
"complete_input_dict": inference_params,
},
)
raise Exception(
"Bedrock HTTPX: Unsupported provider={}, model={}".format(
raise BedrockError(
status_code=400,
message="Bedrock HTTPX: Unsupported provider={}, model={}".format(
provider, model
)
),
)
## COMPLETION CALL

View file

@ -1157,3 +1157,16 @@ def test_bedrock_tools_pt_invalid_names():
assert len(result) == 2
assert result[0]["toolSpec"]["name"] == "a123_invalid_name"
assert result[1]["toolSpec"]["name"] == "another_invalid_name"
def test_bad_request_error():
with pytest.raises(litellm.BadRequestError):
completion(
model="bedrock/bad_model",
messages=[
{
"role": "user",
"content": "What is the meaning of life",
}
],
)