From 1c77b4ed9b4763641e24b11317b57cc2b711c7b3 Mon Sep 17 00:00:00 2001 From: Tuan Le <30828528+tuankg1028@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:06:07 +0700 Subject: [PATCH] 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) --- rag/llm/chat_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index 5170d3d28..c2120cfca 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -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