From bb2880191aede5bf4656207fc3b3c96dd8c60c0b Mon Sep 17 00:00:00 2001 From: 6vision Date: Thu, 4 Jul 2024 01:22:55 +0800 Subject: [PATCH 1/2] update gemini model --- bot/gemini/google_gemini_bot.py | 4 ++-- bridge/bridge.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bot/gemini/google_gemini_bot.py b/bot/gemini/google_gemini_bot.py index 6132b78..6305481 100644 --- a/bot/gemini/google_gemini_bot.py +++ b/bot/gemini/google_gemini_bot.py @@ -24,7 +24,7 @@ class GoogleGeminiBot(Bot): self.api_key = conf().get("gemini_api_key") # 复用文心的token计算方式 self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "gpt-3.5-turbo") - + self.model = conf().get("model") or "gemini-pro" def reply(self, query, context: Context = None) -> Reply: try: if context.type != ContextType.TEXT: @@ -35,7 +35,7 @@ class GoogleGeminiBot(Bot): session = self.sessions.session_query(query, session_id) gemini_messages = self._convert_to_gemini_messages(self.filter_messages(session.messages)) genai.configure(api_key=self.api_key) - model = genai.GenerativeModel('gemini-pro') + model = genai.GenerativeModel(self.model) response = model.generate_content(gemini_messages) reply_text = response.text self.sessions.session_reply(reply_text, session_id) diff --git a/bridge/bridge.py b/bridge/bridge.py index 2432926..b7b3ebf 100644 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -36,7 +36,7 @@ class Bridge(object): self.btype["chat"] = const.QWEN if model_type in [const.QWEN_TURBO, const.QWEN_PLUS, const.QWEN_MAX]: self.btype["chat"] = const.QWEN_DASHSCOPE - if model_type in [const.GEMINI]: + if model_type and model_type.startswith("gemini"): self.btype["chat"] = const.GEMINI if model_type in [const.ZHIPU_AI]: self.btype["chat"] = const.ZHIPU_AI From 87525bb3838f2ff4da2d95dbf40c7936b3e12ff4 Mon Sep 17 00:00:00 2001 From: 6vision Date: Thu, 4 Jul 2024 01:44:53 +0800 Subject: [PATCH 2/2] update gemini model --- bot/gemini/google_gemini_bot.py | 2 ++ common/const.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bot/gemini/google_gemini_bot.py b/bot/gemini/google_gemini_bot.py index 6305481..8a4100a 100644 --- a/bot/gemini/google_gemini_bot.py +++ b/bot/gemini/google_gemini_bot.py @@ -25,6 +25,8 @@ class GoogleGeminiBot(Bot): # 复用文心的token计算方式 self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "gpt-3.5-turbo") self.model = conf().get("model") or "gemini-pro" + if self.model == "gemini": + self.model = "gemini-pro" def reply(self, query, context: Context = None) -> Reply: try: if context.type != ContextType.TEXT: diff --git a/common/const.py b/common/const.py index 638c728..7892dc9 100644 --- a/common/const.py +++ b/common/const.py @@ -11,7 +11,7 @@ QWEN = "qwen" # 旧版通义模型 QWEN_DASHSCOPE = "dashscope" # 通义新版sdk和api key -GEMINI = "gemini" +GEMINI = "gemini" # gemini-1.0-pro ZHIPU_AI = "glm-4" MOONSHOT = "moonshot" MiniMax = "minimax" @@ -51,16 +51,19 @@ LINKAI_35 = "linkai-3.5" LINKAI_4_TURBO = "linkai-4-turbo" LINKAI_4o = "linkai-4o" +GEMINI_PRO = "gemini-1.0-pro" +GEMINI_15_flash = "gemini-1.5-flash" +GEMINI_15_PRO = "gemini-1.5-pro" MODEL_LIST = [ GPT35, GPT35_0125, GPT35_1106, "gpt-3.5-turbo-16k", GPT_4o, GPT4_TURBO, GPT4_TURBO_PREVIEW, GPT4_TURBO_01_25, GPT4_TURBO_11_06, GPT4, GPT4_32k, GPT4_06_13, GPT4_32k_06_13, WEN_XIN, WEN_XIN_4, - XUNFEI, GEMINI, ZHIPU_AI, MOONSHOT, + XUNFEI, ZHIPU_AI, MOONSHOT, MiniMax, + GEMINI, GEMINI_PRO, GEMINI_15_flash, GEMINI_15_PRO, "claude", "claude-3-haiku", "claude-3-sonnet", "claude-3-opus", "claude-3-opus-20240229", "moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k", QWEN, QWEN_TURBO, QWEN_PLUS, QWEN_MAX, - MiniMax, LINKAI_35, LINKAI_4_TURBO, LINKAI_4o ]