diff --git a/haystack/components/builders/chat_prompt_builder.py b/haystack/components/builders/chat_prompt_builder.py index 21a90f785..ff1bb7f7d 100644 --- a/haystack/components/builders/chat_prompt_builder.py +++ b/haystack/components/builders/chat_prompt_builder.py @@ -75,13 +75,13 @@ class ChatPromptBuilder: "template": messages}}) print(res) - >> {'llm': {'replies': [ChatMessage(content="Berlin is the capital city of Germany and one of the most vibrant + >> {'llm': {'replies': [ChatMessage(_role=, _content=[TextContent(text= + "Berlin is the capital city of Germany and one of the most vibrant and diverse cities in Europe. Here are some key things to know...Enjoy your time exploring the vibrant and dynamic - capital of Germany!", role=, name=None, meta={'model': 'gpt-4o-mini', + capital of Germany!")], _name=None, _meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 27, 'completion_tokens': 681, 'total_tokens': 708}})]}} - messages = [system_message, ChatMessage.from_user("What's the weather forecast for {{location}} in the next {{day_count}} days?")] @@ -89,9 +89,10 @@ class ChatPromptBuilder: "template": messages}}) print(res) - >> {'llm': {'replies': [ChatMessage(content="Here is the weather forecast for Berlin in the next 5 + >> {'llm': {'replies': [ChatMessage(_role=, _content=[TextContent(text= + "Here is the weather forecast for Berlin in the next 5 days:\\n\\nDay 1: Mostly cloudy with a high of 22°C (72°F) and...so it's always a good idea to check for updates - closer to your visit.", role=, name=None, meta={'model': 'gpt-4o-mini', + closer to your visit.")], _name=None, _meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 37, 'completion_tokens': 201, 'total_tokens': 238}})]}} ``` diff --git a/haystack/components/connectors/openapi_service.py b/haystack/components/connectors/openapi_service.py index a27ba1373..a4a2814c5 100644 --- a/haystack/components/connectors/openapi_service.py +++ b/haystack/components/connectors/openapi_service.py @@ -188,7 +188,8 @@ class OpenAPIServiceConnector: service_openapi_spec=serperdev_openapi_spec, service_credentials=serper_token) print(result) - >> {'service_response': [ChatMessage(content='{"searchParameters": {"q": "Why was Sam Altman ousted from OpenAI?", + >> {'service_response': [ChatMessage(_role=, _content=[TextContent(text= + >> '{"searchParameters": {"q": "Why was Sam Altman ousted from OpenAI?", >> "type": "search", "engine": "google"}, "answerBox": {"snippet": "Concerns over AI safety and OpenAI\'s role >> in protecting were at the center of Altman\'s brief ouster from the company."... ``` diff --git a/haystack/components/generators/chat/azure.py b/haystack/components/generators/chat/azure.py index 802df2e13..3c09c1deb 100644 --- a/haystack/components/generators/chat/azure.py +++ b/haystack/components/generators/chat/azure.py @@ -57,10 +57,11 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator): ``` {'replies': - [ChatMessage(content='Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on - enabling computers to understand, interpret, and generate human language in a way that is useful.', - role=, name=None, - meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', + [ChatMessage(_role=, _content=[TextContent(text= + "Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on + enabling computers to understand, interpret, and generate human language in a way that is useful.")], + _name=None, + _meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 15, 'completion_tokens': 36, 'total_tokens': 51}})] } ``` diff --git a/haystack/components/generators/chat/hugging_face_local.py b/haystack/components/generators/chat/hugging_face_local.py index ec96c02c2..85269c512 100644 --- a/haystack/components/generators/chat/hugging_face_local.py +++ b/haystack/components/generators/chat/hugging_face_local.py @@ -105,14 +105,14 @@ class HuggingFaceLocalChatGenerator: ``` {'replies': - [ChatMessage(content=' Natural Language Processing (NLP) is a subfield of artificial intelligence that deals + [ChatMessage(_role=, _content=[TextContent(text= + "Natural Language Processing (NLP) is a subfield of artificial intelligence that deals with the interaction between computers and human language. It enables computers to understand, interpret, and generate human language in a valuable way. NLP involves various techniques such as speech recognition, text analysis, sentiment analysis, and machine translation. The ultimate goal is to make it easier for computers to - process and derive meaning from human language, improving communication between humans and machines.', - role=, - name=None, - meta={'finish_reason': 'stop', 'index': 0, 'model': + process and derive meaning from human language, improving communication between humans and machines.")], + _name=None, + _meta={'finish_reason': 'stop', 'index': 0, 'model': 'mistralai/Mistral-7B-Instruct-v0.2', 'usage': {'completion_tokens': 90, 'prompt_tokens': 19, 'total_tokens': 109}}) ] diff --git a/haystack/components/generators/chat/openai.py b/haystack/components/generators/chat/openai.py index 693b12be0..8f0d99cad 100644 --- a/haystack/components/generators/chat/openai.py +++ b/haystack/components/generators/chat/openai.py @@ -67,11 +67,12 @@ class OpenAIChatGenerator: Output: ``` {'replies': - [ChatMessage(content='Natural Language Processing (NLP) is a branch of artificial intelligence + [ChatMessage(_role=, _content= + [TextContent(text="Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on enabling computers to understand, interpret, and generate human language in - a way that is meaningful and useful.', - role=, name=None, - meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', + a way that is meaningful and useful.")], + _name=None, + _meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 15, 'completion_tokens': 36, 'total_tokens': 51}}) ] } diff --git a/haystack/components/validators/json_schema.py b/haystack/components/validators/json_schema.py index 051773113..84e59aff5 100644 --- a/haystack/components/validators/json_schema.py +++ b/haystack/components/validators/json_schema.py @@ -81,8 +81,9 @@ class JsonSchemaValidator: } }) print(result) - >> {'schema_validator': {'validated': [ChatMessage(content='\\n{\\n "name": "John",\\n "age": 30\\n}', - role=, name=None, meta={'model': 'gpt-4-1106-preview', 'index': 0, + >> {'schema_validator': {'validated': [ChatMessage(_role=, + _content=[TextContent(text="\\n{\\n "name": "John",\\n "age": 30\\n}")], + _name=None, _meta={'model': 'gpt-4-1106-preview', 'index': 0, 'finish_reason': 'stop', 'usage': {'completion_tokens': 17, 'prompt_tokens': 20, 'total_tokens': 37}})]}} ``` """