ChatGPTNextWeb/NextChat

[Bug] gemini 对话总结不生效

Open

#5,308 opened on 2024年8月23日

GitHub で見る
 (7 comments) (0 reactions) (1 assignee)TypeScript (87,992 stars) (59,717 forks)batch import
bughelp wanted

説明

📦 部署方式

Other

📌 软件版本

v2.14.2

💻 系统环境

Ubuntu

📌 系统版本

22.04

🌐 浏览器

Chrome

📌 浏览器版本

128.0.6613.84

🐛 问题描述

使用gemini模型时无法总结对话

📷 复现步骤

直接使用gemini模型测试即可

🚦 期望结果

能够正常总结对话

📝 补充信息

似乎google调整了api,导致以下两个问题: 1 当url结尾包含alt=sse,会返回text/event-stream类型,导致期望的json流程出现异常。 2 总结对话返回的json格式与期望的不一样,candidates 在数组里。

临时修改建议:

diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts
index 12d8846..3f835fd 100644
--- a/app/client/platforms/google.ts
+++ b/app/client/platforms/google.ts
@@ -39,8 +39,9 @@ export class GeminiProApi implements LLMApi {
     console.log("[Proxy Endpoint] ", baseUrl, path);
 
     let chatPath = [baseUrl, path].join("/");
-
-    chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse";
+    if (!chatPath.includes("gemini-pro")) {
+      chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse";
+    }
     // if chatPath.startsWith('http') then add key in query string
     if (chatPath.startsWith("http") && accessStore.googleApiKey) {
       chatPath += `&key=${accessStore.googleApiKey}`;
@@ -52,6 +53,7 @@ export class GeminiProApi implements LLMApi {
 
     return (
       res?.candidates?.at(0)?.content?.parts.at(0)?.text ||
+      res?.at(0)?.candidates?.at(0)?.content?.parts.at(0)?.text ||
       res?.error?.message ||
       ""
     );

コントリビューターガイド