mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix(bedrock): treat a region path like the bare id when the cost map does not list it
A deployment like bedrock/us-east-1/<unlisted id> now gets the same tools, reasoning_effort and typo 404 as bedrock/<unlisted id>, so Claude Code works on it and a mistyped one still answers 404.
This commit is contained in:
parent
1f2ca49601
commit
fa9cd8fed3
2 changed files with 8 additions and 5 deletions
|
|
@ -1600,7 +1600,9 @@ def bedrock_model_supports_regex_lookaround(model: str, litellm_params: Mapping[
|
|||
|
||||
|
||||
def bedrock_model_is_unknown(model: str) -> bool:
|
||||
model_id: Final = model.removeprefix("bedrock/")
|
||||
routed_id: Final = model.removeprefix("bedrock/")
|
||||
region, separator, regional_id = routed_id.partition("/")
|
||||
model_id: Final = regional_id if separator and region in get_all_bedrock_regions() else routed_id
|
||||
if "/" in model_id:
|
||||
return False
|
||||
base: Final = get_bedrock_base_model(model_id)
|
||||
|
|
|
|||
|
|
@ -9292,12 +9292,13 @@ def _invalid_model_identifier_reply(sent: list[httpx.Request]):
|
|||
return respond
|
||||
|
||||
|
||||
def test_not_found_error():
|
||||
@pytest.mark.parametrize("model", ["bedrock/bad_model", "bedrock/us-east-1/bad_model"])
|
||||
def test_not_found_error(model):
|
||||
sent: Final[list[httpx.Request]] = []
|
||||
|
||||
with pytest.raises(litellm.NotFoundError) as exc_info:
|
||||
completion(
|
||||
model="bedrock/bad_model",
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": "What is the meaning of life"}],
|
||||
client=HTTPHandler(
|
||||
client=httpx.Client(transport=httpx.MockTransport(_invalid_model_identifier_reply(sent)))
|
||||
|
|
@ -9371,8 +9372,8 @@ def _converse_tool_call_reply(sent: list[httpx.Request]):
|
|||
return respond
|
||||
|
||||
|
||||
def test_model_missing_from_cost_map_sends_tools_to_converse():
|
||||
model: Final = "bedrock/us.newvendor.model-1"
|
||||
@pytest.mark.parametrize("model", ["bedrock/us.newvendor.model-1", "bedrock/us-east-1/us.newvendor.model-1"])
|
||||
def test_model_missing_from_cost_map_sends_tools_to_converse(model):
|
||||
assert "us.newvendor.model-1" not in litellm.model_cost
|
||||
sent: Final[list[httpx.Request]] = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue