Skip to content

Commit 81f7b2e

Browse files
committed
fix: raise ValueError when 'model' is passed instead of 'model_name' in BedrockEmbedding
BedrockEmbedding accepts model_name to specify the Bedrock model ID, but passing model= was silently ignored, causing the default model to be used unexpectedly. This adds an explicit check that raises a clear ValueError guiding users to use model_name instead.
1 parent 59b4cc6 commit 81f7b2e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llama-index-integrations/embeddings/llama-index-embeddings-bedrock/llama_index/embeddings/bedrock/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ def __init__(
147147
output_parser: Optional[BaseOutputParser] = None,
148148
**kwargs: Any,
149149
):
150+
if "model" in kwargs:
151+
raise ValueError(
152+
"The 'model' parameter is not supported. "
153+
"Please use 'model_name' instead to specify the Bedrock model ID."
154+
)
155+
150156
additional_kwargs = additional_kwargs or {}
151157

152158
session_kwargs = {

llama-index-integrations/embeddings/llama-index-embeddings-bedrock/tests/test_bedrock_embedding.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ def test_class():
99
assert BaseEmbedding.__name__ in names_of_base_classes
1010

1111

12+
def test_model_param_raises_error():
13+
"""Test that passing 'model' instead of 'model_name' raises ValueError."""
14+
bedrock_client = boto3.client("bedrock-runtime", region_name="us-east-1")
15+
with pytest.raises(ValueError, match="Please use 'model_name' instead"):
16+
BedrockEmbedding(model="cohere.embed-multilingual-v3", client=bedrock_client)
17+
18+
1219
def test_get_provider_two_part_format():
1320
"""Test _get_provider with 2-part model names (provider.model)."""
1421
bedrock_client = boto3.client("bedrock-runtime", region_name="us-east-1")

0 commit comments

Comments
 (0)