From 62f68f5073663b717d7d73239cac97810efa514c Mon Sep 17 00:00:00 2001 From: Vladimir Blagojevic Date: Thu, 21 Nov 2024 10:24:17 +0100 Subject: [PATCH 1/3] AmazonBedrockChatGenerator with Claude raises moot warning for stream kwarg --- .../components/generators/amazon_bedrock/chat/adapters.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py index f5e8f8181..ff2dac713 100644 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py @@ -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 From f45ebe28b1fe68a92e5ed6dadb15bd261eacf296 Mon Sep 17 00:00:00 2001 From: Vladimir Blagojevic Date: Thu, 21 Nov 2024 10:42:21 +0100 Subject: [PATCH 2/3] Retire meta.llama2-13b-chat-v1 from tests --- integrations/amazon_bedrock/tests/test_chat_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/amazon_bedrock/tests/test_chat_generator.py b/integrations/amazon_bedrock/tests/test_chat_generator.py index 571e03eb2..185a34c8a 100644 --- a/integrations/amazon_bedrock/tests/test_chat_generator.py +++ b/integrations/amazon_bedrock/tests/test_chat_generator.py @@ -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", From c3b111b0dd394007a5f7f70feaeab91ffffec3c6 Mon Sep 17 00:00:00 2001 From: Vladimir Blagojevic Date: Thu, 21 Nov 2024 11:11:30 +0100 Subject: [PATCH 3/3] AmazonBedrockChatGenerator with Mistral raises moot warning for stream kwarg --- .../components/generators/amazon_bedrock/chat/adapters.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py index ff2dac713..cbb5ee370 100644 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py @@ -386,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