diff --git a/integrations/meta_llama/tests/test_llama_chat_generator.py b/integrations/meta_llama/tests/test_llama_chat_generator.py index 34b78b4630..990e3f7c79 100644 --- a/integrations/meta_llama/tests/test_llama_chat_generator.py +++ b/integrations/meta_llama/tests/test_llama_chat_generator.py @@ -239,36 +239,6 @@ def test_run_with_params(self, chat_messages, mock_chat_completion, monkeypatch) assert len(response["replies"]) == 1 assert [isinstance(reply, ChatMessage) for reply in response["replies"]] - def test_check_abnormal_completions(self, caplog): - component = MetaLlamaChatGenerator(api_key=Secret.from_token("test-api-key")) - messages = [ - ChatMessage.from_assistant( - "", - meta={ - "finish_reason": "content_filter" if i % 2 == 0 else "length", - "index": i, - }, - ) - for i, _ in enumerate(range(4)) - ] - - for m in messages: - component._check_finish_reason(m.meta) - - # check truncation warning - message_template = ( - "The completion for index {index} has been truncated before reaching a natural stopping point. " - "Increase the max_tokens parameter to allow for longer completions." - ) - - for index in [1, 3]: - assert caplog.records[index].message == message_template.format(index=index) - - # check content filter warning - message_template = "The completion for index {index} has been truncated due to the content filter." - for index in [0, 2]: - assert caplog.records[index].message == message_template.format(index=index) - @pytest.mark.skipif( not os.environ.get("LLAMA_API_KEY", None), reason="Export an env var called LLAMA_API_KEY containing the OpenAI API key to run this test.", diff --git a/integrations/mistral/tests/test_mistral_chat_generator.py b/integrations/mistral/tests/test_mistral_chat_generator.py index b17d779dba..07998b8069 100644 --- a/integrations/mistral/tests/test_mistral_chat_generator.py +++ b/integrations/mistral/tests/test_mistral_chat_generator.py @@ -208,32 +208,6 @@ def test_run_with_params(self, chat_messages, mock_chat_completion, monkeypatch) assert len(response["replies"]) == 1 assert [isinstance(reply, ChatMessage) for reply in response["replies"]] - def test_check_abnormal_completions(self, caplog): - component = MistralChatGenerator(api_key=Secret.from_token("test-api-key")) - messages = [ - ChatMessage.from_assistant( - "", meta={"finish_reason": "content_filter" if i % 2 == 0 else "length", "index": i} - ) - for i, _ in enumerate(range(4)) - ] - - for m in messages: - component._check_finish_reason(m.meta) - - # check truncation warning - message_template = ( - "The completion for index {index} has been truncated before reaching a natural stopping point. " - "Increase the max_tokens parameter to allow for longer completions." - ) - - for index in [1, 3]: - assert caplog.records[index].message == message_template.format(index=index) - - # check content filter warning - message_template = "The completion for index {index} has been truncated due to the content filter." - for index in [0, 2]: - assert caplog.records[index].message == message_template.format(index=index) - @pytest.mark.skipif( not os.environ.get("MISTRAL_API_KEY", None), reason="Export an env var called MISTRAL_API_KEY containing the OpenAI API key to run this test.", diff --git a/integrations/openrouter/tests/test_openrouter_chat_generator.py b/integrations/openrouter/tests/test_openrouter_chat_generator.py index 2bac2ce234..101617a78c 100644 --- a/integrations/openrouter/tests/test_openrouter_chat_generator.py +++ b/integrations/openrouter/tests/test_openrouter_chat_generator.py @@ -240,32 +240,6 @@ def test_run_with_params(self, chat_messages, mock_chat_completion, monkeypatch) assert len(response["replies"]) == 1 assert [isinstance(reply, ChatMessage) for reply in response["replies"]] - def test_check_abnormal_completions(self, caplog): - component = OpenRouterChatGenerator(api_key=Secret.from_token("test-api-key")) - messages = [ - ChatMessage.from_assistant( - "", meta={"finish_reason": "content_filter" if i % 2 == 0 else "length", "index": i} - ) - for i, _ in enumerate(range(4)) - ] - - for m in messages: - component._check_finish_reason(m.meta) - - # check truncation warning - message_template = ( - "The completion for index {index} has been truncated before reaching a natural stopping point. " - "Increase the max_tokens parameter to allow for longer completions." - ) - - for index in [1, 3]: - assert caplog.records[index].message == message_template.format(index=index) - - # check content filter warning - message_template = "The completion for index {index} has been truncated due to the content filter." - for index in [0, 2]: - assert caplog.records[index].message == message_template.format(index=index) - @pytest.mark.skipif( not os.environ.get("OPENROUTER_API_KEY", None), reason="Export an env var called OPENROUTER_API_KEY containing the OpenRouter API key to run this test.", diff --git a/integrations/stackit/tests/test_stackit_chat_generator.py b/integrations/stackit/tests/test_stackit_chat_generator.py index 82cfc12ba9..b50c4f7c3c 100644 --- a/integrations/stackit/tests/test_stackit_chat_generator.py +++ b/integrations/stackit/tests/test_stackit_chat_generator.py @@ -199,39 +199,6 @@ def test_run_with_params(self, chat_messages, mock_chat_completion, monkeypatch) assert len(response["replies"]) == 1 assert [isinstance(reply, ChatMessage) for reply in response["replies"]] - def test_check_abnormal_completions(self, caplog): - component = STACKITChatGenerator( - model="neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8", api_key=Secret.from_token("test-api-key") - ) - messages = [ - ChatMessage.from_assistant( - "", meta={"finish_reason": "content_filter" if i % 2 == 0 else "length", "index": i} - ) - for i, _ in enumerate(range(4)) - ] - - for m in messages: - try: - # Haystack >= 2.9.0 - component._check_finish_reason(m.meta) - except AttributeError: - # Haystack < 2.9.0 - component._check_finish_reason(m) - - # check truncation warning - message_template = ( - "The completion for index {index} has been truncated before reaching a natural stopping point. " - "Increase the max_tokens parameter to allow for longer completions." - ) - - for index in [1, 3]: - assert caplog.records[index].message == message_template.format(index=index) - - # check content filter warning - message_template = "The completion for index {index} has been truncated due to the content filter." - for index in [0, 2]: - assert caplog.records[index].message == message_template.format(index=index) - @pytest.mark.skipif( not os.environ.get("STACKIT_API_KEY", None), reason="Export an env var called STACKIT_API_KEY containing the API key to run this test.",