Skip to content

Commit 690e767

Browse files
authored
chore: Remove 4 redundant Meta Llama integration tests (#2646)
* Remove 4 redundant integration tests * Linter
1 parent 1133b2d commit 690e767

2 files changed

Lines changed: 1 addition & 119 deletions

File tree

integrations/meta_llama/tests/test_llama_chat_generator.py

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from haystack import Pipeline
1111
from haystack.components.generators.utils import print_streaming_chunk
1212
from haystack.components.tools import ToolInvoker
13-
from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk, ToolCall
13+
from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk
1414
from haystack.tools import Tool, Toolset
1515
from haystack.utils.auth import Secret
1616
from openai import OpenAIError
@@ -387,61 +387,6 @@ class NobelPrizeInfo(BaseModel):
387387
assert "achievement_description" in msg
388388
assert msg["nationality"] == "American"
389389

390-
@pytest.mark.skipif(
391-
not os.environ.get("LLAMA_API_KEY", None),
392-
reason="Export an env var called LLAMA_API_KEY containing the Llama API key to run this test.",
393-
)
394-
@pytest.mark.integration
395-
def test_live_run_with_response_format_json_schema(self):
396-
response_schema = {
397-
"type": "json_schema",
398-
"json_schema": {
399-
"name": "CapitalCity",
400-
"strict": True,
401-
"schema": {
402-
"title": "CapitalCity",
403-
"type": "object",
404-
"properties": {
405-
"city": {"title": "City", "type": "string"},
406-
"country": {"title": "Country", "type": "string"},
407-
},
408-
"required": ["city", "country"],
409-
"additionalProperties": False,
410-
},
411-
},
412-
}
413-
414-
chat_messages = [ChatMessage.from_user("What's the capital of France?")]
415-
comp = MetaLlamaChatGenerator(generation_kwargs={"response_format": response_schema})
416-
results = comp.run(chat_messages)
417-
assert len(results["replies"]) == 1
418-
message: ChatMessage = results["replies"][0]
419-
msg = json.loads(message.text)
420-
assert "Paris" in msg["city"]
421-
assert isinstance(msg["country"], str)
422-
assert "France" in msg["country"]
423-
assert message.meta["finish_reason"] == "stop"
424-
425-
@pytest.mark.skipif(
426-
not os.environ.get("LLAMA_API_KEY", None),
427-
reason="Export an env var called LLAMA_API_KEY containing the OpenAI API key to run this test.",
428-
)
429-
@pytest.mark.integration
430-
def test_live_run_with_tools(self, tools):
431-
chat_messages = [ChatMessage.from_user("What's the weather like in Paris?")]
432-
component = MetaLlamaChatGenerator(tools=tools)
433-
results = component.run(chat_messages)
434-
assert len(results["replies"]) == 1
435-
message = results["replies"][0]
436-
assert message.text is None
437-
438-
assert message.tool_calls
439-
tool_call = message.tool_call
440-
assert isinstance(tool_call, ToolCall)
441-
assert tool_call.tool_name == "weather"
442-
assert tool_call.arguments == {"city": "Paris"}
443-
assert message.meta["finish_reason"] == "tool_calls"
444-
445390
@pytest.mark.skipif(
446391
not os.environ.get("LLAMA_API_KEY", None),
447392
reason="Export an env var called LLAMA_API_KEY containing the OpenAI API key to run this test.",

integrations/meta_llama/tests/test_llama_chat_generator_async.py

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,6 @@ async def test_run_async_with_params(self, chat_messages, mock_async_chat_comple
121121
assert len(response["replies"]) == 1
122122
assert [isinstance(reply, ChatMessage) for reply in response["replies"]]
123123

124-
@pytest.mark.skipif(
125-
not os.environ.get("LLAMA_API_KEY", None),
126-
reason="Export an env var called LLAMA_API_KEY containing the Llama API key to run this test.",
127-
)
128-
@pytest.mark.integration
129-
@pytest.mark.asyncio
130-
async def test_live_run_async(self):
131-
chat_messages = [ChatMessage.from_user("What's the capital of France")]
132-
component = MetaLlamaChatGenerator()
133-
results = await component.run_async(chat_messages)
134-
assert len(results["replies"]) == 1
135-
message: ChatMessage = results["replies"][0]
136-
assert "Paris" in message.text
137-
assert "Llama-4-Scout-17B-16E-Instruct-FP8" in message.meta["model"]
138-
assert message.meta["finish_reason"] == "stop"
139-
140124
@pytest.mark.skipif(
141125
not os.environ.get("LLAMA_API_KEY", None),
142126
reason="Export an env var called LLAMA_API_KEY containing the Llama API key to run this test.",
@@ -212,50 +196,3 @@ async def test_live_run_with_tools_and_response_async(self, tools):
212196
assert not final_message.tool_call
213197
assert len(final_message.text) > 0
214198
assert "paris" in final_message.text.lower()
215-
216-
@pytest.mark.skipif(
217-
not os.environ.get("LLAMA_API_KEY", None),
218-
reason="Export an env var called LLAMA_API_KEY containing the Llama API key to run this test.",
219-
)
220-
@pytest.mark.integration
221-
@pytest.mark.asyncio
222-
async def test_live_run_with_tools_streaming_async(self, tools):
223-
"""
224-
Integration test that the MetaLlamaChatGenerator component can run with tools and streaming.
225-
"""
226-
227-
counter = 0
228-
tool_calls = []
229-
230-
async def callback(chunk: StreamingChunk):
231-
nonlocal counter
232-
nonlocal tool_calls
233-
counter += 1
234-
if chunk.meta.get("tool_calls"):
235-
tool_calls.extend(chunk.meta["tool_calls"])
236-
237-
component = MetaLlamaChatGenerator(tools=tools, streaming_callback=callback)
238-
results = await component.run_async(
239-
[ChatMessage.from_user("What's the weather like in Paris?")],
240-
)
241-
242-
assert len(results["replies"]) > 0, "No replies received"
243-
assert counter > 1, "Streaming callback was not called multiple times"
244-
assert tool_calls, "No tool calls received in streaming"
245-
246-
# Find the message with tool calls
247-
tool_message = None
248-
for message in results["replies"]:
249-
if message.tool_call:
250-
tool_message = message
251-
break
252-
253-
assert tool_message is not None, "No message with tool call found"
254-
assert isinstance(tool_message, ChatMessage), "Tool message is not a ChatMessage instance"
255-
assert ChatMessage.is_from(tool_message, ChatRole.ASSISTANT), "Tool message is not from the assistant"
256-
257-
tool_call = tool_message.tool_call
258-
assert tool_call.id, "Tool call does not contain value for 'id' key"
259-
assert tool_call.tool_name == "weather"
260-
assert tool_call.arguments == {"city": "Paris"}
261-
assert tool_message.meta["finish_reason"] == "tool_calls"

0 commit comments

Comments
 (0)