Skip to content

Commit 2f52cad

Browse files
authored
docs: ChatMessage examples (#1752)
1 parent bb04a77 commit 2f52cad

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/vertex_chat_generator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ class AnthropicVertexChatGenerator(AnthropicChatGenerator):
5151
response = client.run(messages)
5252
print(response)
5353
54-
>> {'replies': [ChatMessage(content='Natural Language Processing (NLP) is a field of artificial intelligence that
54+
>> {'replies': [ChatMessage(_role=<ChatRole.ASSISTANT: 'assistant'>, _content=[TextContent(text=
55+
>> "Natural Language Processing (NLP) is a field of artificial intelligence that
5556
>> focuses on enabling computers to understand, interpret, and generate human language. It involves developing
5657
>> techniques and algorithms to analyze and process text or speech data, allowing machines to comprehend and
57-
>> communicate in natural languages like English, Spanish, or Chinese.', role=<ChatRole.ASSISTANT: 'assistant'>,
58-
>> name=None, meta={'model': 'claude-3-sonnet@20240229', 'index': 0, 'finish_reason': 'end_turn',
58+
>> communicate in natural languages like English, Spanish, or Chinese.")],
59+
>> _name=None, _meta={'model': 'claude-3-sonnet@20240229', 'index': 0, 'finish_reason': 'end_turn',
5960
>> 'usage': {'input_tokens': 15, 'output_tokens': 64}})]}
6061
```
6162

integrations/mistral/src/haystack_integrations/components/generators/mistral/chat/chat_generator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ class MistralChatGenerator(OpenAIChatGenerator):
4848
response = client.run(messages)
4949
print(response)
5050
51-
>>{'replies': [ChatMessage(content='Natural Language Processing (NLP) is a branch of artificial intelligence
52-
>>that focuses on enabling computers to understand, interpret, and generate human language in a way that is
53-
>>meaningful and useful.', role=<ChatRole.ASSISTANT: 'assistant'>, name=None,
54-
>>meta={'model': 'mistral-small-latest', 'index': 0, 'finish_reason': 'stop',
55-
>>'usage': {'prompt_tokens': 15, 'completion_tokens': 36, 'total_tokens': 51}})]}
51+
>>{'replies': [ChatMessage(_role=<ChatRole.ASSISTANT: 'assistant'>, _content=[TextContent(text=
52+
>> "Natural Language Processing (NLP) is a branch of artificial intelligence
53+
>> that focuses on enabling computers to understand, interpret, and generate human language in a way that is
54+
>> meaningful and useful.")], _name=None,
55+
>> _meta={'model': 'mistral-small-latest', 'index': 0, 'finish_reason': 'stop',
56+
>> 'usage': {'prompt_tokens': 15, 'completion_tokens': 36, 'total_tokens': 51}})]}
5657
```
5758
"""
5859

0 commit comments

Comments
 (0)