diff --git a/bot/gemini/google_gemini_bot.py b/bot/gemini/google_gemini_bot.py index 6132b78..8a4100a 100644 --- a/bot/gemini/google_gemini_bot.py +++ b/bot/gemini/google_gemini_bot.py @@ -24,7 +24,9 @@ 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" + if self.model == "gemini": + self.model = "gemini-pro" def reply(self, query, context: Context = None) -> Reply: try: if context.type != ContextType.TEXT: @@ -35,7 +37,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 diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 6e2a45c..27f3af0 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -117,6 +117,7 @@ class ChatChannel(Channel): logger.info("[chat_channel]receive group at") if not conf().get("group_at_off", False): flag = True + self.name = self.name if self.name is not None else "" # 部分渠道self.name可能没有赋值 pattern = f"@{re.escape(self.name)}(\u2005|\u0020)" subtract_res = re.sub(pattern, r"", content) if isinstance(context["msg"].at_list, list): diff --git a/channel/dingtalk/dingtalk_channel.py b/channel/dingtalk/dingtalk_channel.py index cbe522f..9128d95 100644 --- a/channel/dingtalk/dingtalk_channel.py +++ b/channel/dingtalk/dingtalk_channel.py @@ -163,7 +163,7 @@ class DingTalkChanel(ChatChannel, dingtalk_stream.ChatbotHandler): elif cmsg.ctype == ContextType.PATPAT: logger.debug("[DingTalk]receive patpat msg: {}".format(cmsg.content)) elif cmsg.ctype == ContextType.TEXT: - logger.debug("[DingTalk]receive patpat msg: {}".format(cmsg.content)) + logger.debug("[DingTalk]receive text msg: {}".format(cmsg.content)) else: logger.debug("[DingTalk]receive other msg: {}".format(cmsg.content)) context = self._compose_context(cmsg.ctype, cmsg.content, isgroup=True, msg=cmsg) diff --git a/channel/dingtalk/dingtalk_message.py b/channel/dingtalk/dingtalk_message.py index 1bba85d..c069a1b 100644 --- a/channel/dingtalk/dingtalk_message.py +++ b/channel/dingtalk/dingtalk_message.py @@ -49,6 +49,7 @@ class DingTalkMessage(ChatMessage): if self.is_group: self.from_user_id = event.conversation_id self.actual_user_id = event.sender_id + self.is_at = True else: self.from_user_id = event.sender_id self.actual_user_id = event.sender_id diff --git a/common/const.py b/common/const.py index 655848f..45e72e7 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", "claude-3.5-sonnet", "moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k", QWEN, QWEN_TURBO, QWEN_PLUS, QWEN_MAX, - MiniMax, LINKAI_35, LINKAI_4_TURBO, LINKAI_4o ] diff --git a/config.py b/config.py index 7f485aa..26f073d 100644 --- a/config.py +++ b/config.py @@ -17,7 +17,7 @@ available_setting = { "open_ai_api_base": "https://api.openai.com/v1", "proxy": "", # openai使用的代理 # chatgpt模型, 当use_azure_chatgpt为true时,其名称为Azure上model deployment名称 - "model": "gpt-3.5-turbo", # 支持ChatGPT、Claude、Gemini、文心一言、通义千问、Kimi、讯飞星火、智谱、LinkAI等模型,模型具体名称详见common/const.py文件列出的模型 + "model": "gpt-3.5-turbo", # 可选择: gpt-4o, gpt-4-turbo, claude-3-sonnet, wenxin, moonshot, qwen-turbo, xunfei, glm-4, minimax, gemini等模型,全部可选模型详见common/const.py文件 "bot_type": "", # 可选配置,使用兼容openai格式的三方服务时候,需填"chatGPT"。bot具体名称详见common/const.py文件列出的bot_type,如不填根据model名称判断, "use_azure_chatgpt": False, # 是否使用azure的chatgpt "azure_deployment_id": "", # azure 模型部署名称 @@ -96,7 +96,7 @@ available_setting = { "voice_reply_voice": False, # 是否使用语音回复语音,需要设置对应语音合成引擎的api key "always_reply_voice": False, # 是否一直使用语音回复 "voice_to_text": "openai", # 语音识别引擎,支持openai,baidu,google,azure - "text_to_voice": "openai", # 语音合成引擎,支持openai,baidu,google,pytts(offline),azure,elevenlabs,edge(online) + "text_to_voice": "openai", # 语音合成引擎,支持openai,baidu,google,pytts(offline),ali,azure,elevenlabs,edge(online) "text_to_voice_model": "tts-1", "tts_voice_id": "alloy", # baidu 语音api配置, 使用百度语音识别和语音合成时需要 @@ -242,7 +242,7 @@ def drag_sensitive(config): conf_dict_copy = copy.deepcopy(conf_dict) for key in conf_dict_copy: if "key" in key or "secret" in key: - if isinstance(key, str): + if isinstance(conf_dict_copy[key], str): conf_dict_copy[key] = conf_dict_copy[key][0:3] + "*" * 5 + conf_dict_copy[key][-3:] return json.dumps(conf_dict_copy, indent=4) @@ -250,7 +250,7 @@ def drag_sensitive(config): config_copy = copy.deepcopy(config) for key in config: if "key" in key or "secret" in key: - if isinstance(key, str): + if isinstance(config_copy[key], str): config_copy[key] = config_copy[key][0:3] + "*" * 5 + config_copy[key][-3:] return config_copy except Exception as e: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 8dbb1e4..39fdffb 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -6,6 +6,7 @@ services: security_opt: - seccomp:unconfined environment: + TZ: 'Asia/Shanghai' OPEN_AI_API_KEY: 'YOUR API KEY' MODEL: 'gpt-3.5-turbo' PROXY: '' diff --git a/plugins/source.json b/plugins/source.json index bc7460e..c5c99d0 100644 --- a/plugins/source.json +++ b/plugins/source.json @@ -35,6 +35,10 @@ "solitaire": { "url": "https://github.com/Wang-zhechao/solitaire.git", "desc": "机器人微信接龙插件" + }, + "HighSpeedTicket": { + "url": "https://github.com/He0607/HighSpeedTicket.git", + "desc": "高铁(火车)票查询插件" } } }