fix: Correctly format message parts in GoogleChat (#8596)

### What problem does this PR solve?

This PR addresses an incompatibility issue with the Google Chat API by
correcting the message content format in the `GoogleChat` class.
Previously, the content was directly assigned to the "parts" field,
which did not align with the API's expected format. This change ensures
that messages are properly formatted with a "text" key within a
dictionary, as required by the API.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Tuan Le
2025-07-01 13:06:07 +07:00
committed by GitHub
parent e3edcc3064
commit 1c77b4ed9b

View File

@ -1596,7 +1596,9 @@ class GoogleChat(Base):
if "role" in item and item["role"] == "assistant":
item["role"] = "model"
if "content" in item:
item["parts"] = item.pop("content")
item["parts"] = [{
"text": item.pop("content"),
}]
response = self.client.generate_content(hist, generation_config=gen_conf)
ans = response.text