浏览代码

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)
tags/v0.20.0
Tuan Le 4 个月前
父节点
当前提交
1c77b4ed9b
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3
    1
      rag/llm/chat_model.py

+ 3
- 1
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

正在加载...
取消
保存