Skip to content

Commit

Permalink
fix: AmazonBedrockChatGenerator with Claude raises moot warning for s…
Browse files Browse the repository at this point in the history
…tream… (#1205)

* AmazonBedrockChatGenerator with Claude raises moot warning for stream kwarg

* Retire meta.llama2-13b-chat-v1 from tests

* AmazonBedrockChatGenerator with Mistral raises moot warning for stream kwarg
  • Loading branch information
vblagoje authored Nov 21, 2024
1 parent 16bc80f commit 028e2c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ def prepare_body(self, messages: List[ChatMessage], **inference_kwargs) -> Dict[
stop_sequences = inference_kwargs.get("stop_sequences", []) + inference_kwargs.pop("stop_words", [])
if stop_sequences:
inference_kwargs["stop_sequences"] = stop_sequences
# pop stream kwarg from inference_kwargs as Anthropic does not support it (if provided)
inference_kwargs.pop("stream", None)
params = self._get_params(inference_kwargs, default_params, self.ALLOWED_PARAMS)
body = {**self.prepare_chat_messages(messages=messages), **params}
return body
Expand Down Expand Up @@ -384,6 +386,10 @@ def prepare_body(self, messages: List[ChatMessage], **inference_kwargs) -> Dict[
stop_words = inference_kwargs.pop("stop_words", [])
if stop_words:
inference_kwargs["stop"] = stop_words

# pop stream kwarg from inference_kwargs as Mistral does not support it (if provided)
inference_kwargs.pop("stream", None)

params = self._get_params(inference_kwargs, default_params, self.ALLOWED_PARAMS)
body = {"prompt": self.prepare_chat_messages(messages=messages), **params}
return body
Expand Down
2 changes: 1 addition & 1 deletion integrations/amazon_bedrock/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)

KLASS = "haystack_integrations.components.generators.amazon_bedrock.chat.chat_generator.AmazonBedrockChatGenerator"
MODELS_TO_TEST = ["anthropic.claude-3-sonnet-20240229-v1:0", "anthropic.claude-v2:1", "meta.llama2-13b-chat-v1"]
MODELS_TO_TEST = ["anthropic.claude-3-sonnet-20240229-v1:0", "anthropic.claude-v2:1"]
MODELS_TO_TEST_WITH_TOOLS = ["anthropic.claude-3-haiku-20240307-v1:0"]
MISTRAL_MODELS = [
"mistral.mistral-7b-instruct-v0:2",
Expand Down

0 comments on commit 028e2c3

Please sign in to comment.