Skip to content

Commit

Permalink
chatmessage - access text instead of content (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 authored Dec 12, 2024
1 parent 7174d35 commit 64d9ab2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integrations/cerebras.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ while True:
messages.append(ChatMessage.from_user(msg))
response = generator.run(messages=messages)
assistant_resp = response['replies'][0]
print("🤖 "+assistant_resp.content)
print("🤖 "+assistant_resp.text)
messages.append(assistant_resp)
```
5 changes: 3 additions & 2 deletions integrations/google-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ When chatting with Gemini we can also use function calls.
```python
import os
import json
from google.ai.generativelanguage import FunctionDeclaration, Tool
from haystack.dataclasses import ChatMessage
Expand Down Expand Up @@ -161,14 +162,14 @@ messages = [
ChatMessage.from_user(content="What is the temperature in celsius in Berlin?")
]
res = gemini_chat.run(messages=messages)
weather = get_current_weather(**res["replies"][0].content)
weather = get_current_weather(**json.loads(res["replies"][0].text))
messages += res["replies"] + [
ChatMessage.from_function(content=weather, name="get_current_weather")
]
res = gemini_chat.run(messages=messages)
print(res["replies"][0].content)
print(res["replies"][0].text)
```
Will output:
Expand Down
2 changes: 1 addition & 1 deletion integrations/groq.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ while True:
messages.append(ChatMessage.from_user(msg))
response = generator.run(messages=messages)
assistant_resp = response['replies'][0]
print("🤖 "+assistant_resp.content)
print("🤖 "+assistant_resp.text)
messages.append(assistant_resp)
```
3 changes: 2 additions & 1 deletion integrations/monsterapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ while True:
messages.append(ChatMessage.from_user(msg))
response = generator.run(messages=messages)
assistant_resp = response['replies'][0]
print(assistant_resp.content)
print(assistant_resp.text)
messages.append(assistant_resp)
```

2 changes: 1 addition & 1 deletion integrations/ollama.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ client = OllamaChatGenerator(model="orca-mini", timeout=45, url="http://localhos

response = client.run(messages, generation_kwargs={"temperature": 0.2})

print(response["replies"][0].content)
print(response["replies"][0].text)

```
You should receive an output like (output is not deterministic):
Expand Down

0 comments on commit 64d9ab2

Please sign in to comment.