|
10 | 10 | from haystack import Pipeline |
11 | 11 | from haystack.components.generators.utils import print_streaming_chunk |
12 | 12 | from haystack.components.tools import ToolInvoker |
13 | | -from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk, ToolCall |
| 13 | +from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk |
14 | 14 | from haystack.tools import Tool, Toolset |
15 | 15 | from haystack.utils.auth import Secret |
16 | 16 | from openai import OpenAIError |
@@ -387,61 +387,6 @@ class NobelPrizeInfo(BaseModel): |
387 | 387 | assert "achievement_description" in msg |
388 | 388 | assert msg["nationality"] == "American" |
389 | 389 |
|
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 | | - |
445 | 390 | @pytest.mark.skipif( |
446 | 391 | not os.environ.get("LLAMA_API_KEY", None), |
447 | 392 | reason="Export an env var called LLAMA_API_KEY containing the OpenAI API key to run this test.", |
|
0 commit comments