From 6eb3c90e1847c676d4455a81a5b8698bb311cc68 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Fri, 8 Dec 2023 14:12:21 +0800 Subject: [PATCH] feat: qwen model modify --- bot/bot_factory.py | 2 +- bot/tongyi/tongyi_qwen_bot.py | 12 ++++++------ bridge/bridge.py | 4 ++-- common/const.py | 4 ++-- config.py | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bot/bot_factory.py b/bot/bot_factory.py index f618479..a0edde1 100644 --- a/bot/bot_factory.py +++ b/bot/bot_factory.py @@ -44,7 +44,7 @@ def create_bot(bot_type): from bot.claude.claude_ai_bot import ClaudeAIBot return ClaudeAIBot() - elif bot_type == const.TONGYI: + elif bot_type == const.QWEN: from bot.tongyi.tongyi_qwen_bot import TongyiQwenBot return TongyiQwenBot() raise RuntimeError diff --git a/bot/tongyi/tongyi_qwen_bot.py b/bot/tongyi/tongyi_qwen_bot.py index d123dae..585cb47 100644 --- a/bot/tongyi/tongyi_qwen_bot.py +++ b/bot/tongyi/tongyi_qwen_bot.py @@ -20,14 +20,14 @@ from config import conf, load_config class TongyiQwenBot(Bot): def __init__(self): super().__init__() - self.access_key_id = conf().get("tongyi_access_key_id") - self.access_key_secret = conf().get("tongyi_access_key_secret") - self.agent_key = conf().get("tongyi_agent_key") - self.app_id = conf().get("tongyi_app_id") - self.node_id = conf().get("tongyi_node_id") + self.access_key_id = conf().get("qwen_access_key_id") + self.access_key_secret = conf().get("qwen_access_key_secret") + self.agent_key = conf().get("qwen_agent_key") + self.app_id = conf().get("qwen_app_id") + self.node_id = conf().get("qwen_node_id") or "" self.api_key_client = broadscope_bailian.AccessTokenClient(access_key_id=self.access_key_id, access_key_secret=self.access_key_secret) self.api_key_expired_time = self.set_api_key() - self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "tongyi") + self.sessions = SessionManager(BaiduWenxinSession, model=conf().get("model") or "qwen") self.temperature = conf().get("temperature", 0.2) # 值在[0,1]之间,越大表示回复越具有不确定性 self.top_p = conf().get("top_p", 1) diff --git a/bridge/bridge.py b/bridge/bridge.py index ea8de13..be951af 100644 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -35,8 +35,8 @@ class Bridge(object): self.btype["text_to_voice"] = const.LINKAI if model_type in ["claude"]: self.btype["chat"] = const.CLAUDEAI - if model_type in ["tongyi"]: - self.btype["chat"] = const.TONGYI + if model_type in [const.QWEN]: + self.btype["chat"] = const.QWEN self.bots = {} self.chat_bots = {} diff --git a/common/const.py b/common/const.py index 9ecd1a2..fc74e64 100644 --- a/common/const.py +++ b/common/const.py @@ -6,7 +6,7 @@ XUNFEI = "xunfei" CHATGPTONAZURE = "chatGPTOnAzure" LINKAI = "linkai" CLAUDEAI = "claude" -TONGYI = "tongyi" +QWEN = "qwen" # model GPT35 = "gpt-3.5-turbo" @@ -17,7 +17,7 @@ WHISPER_1 = "whisper-1" TTS_1 = "tts-1" TTS_1_HD = "tts-1-hd" -MODEL_LIST = ["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4", "wenxin", "wenxin-4", "xunfei", "claude", "gpt-4-turbo", GPT4_TURBO_PREVIEW, "tongyi"] +MODEL_LIST = ["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4", "wenxin", "wenxin-4", "xunfei", "claude", "gpt-4-turbo", GPT4_TURBO_PREVIEW, QWEN] # channel FEISHU = "feishu" diff --git a/config.py b/config.py index 728f308..8300699 100644 --- a/config.py +++ b/config.py @@ -16,7 +16,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", # 还支持 gpt-4, gpt-4-turbo, wenxin, xunfei, tongyi + "model": "gpt-3.5-turbo", # 还支持 gpt-4, gpt-4-turbo, wenxin, xunfei, qwen "use_azure_chatgpt": False, # 是否使用azure的chatgpt "azure_deployment_id": "", # azure 模型部署名称 "azure_api_version": "", # azure api版本 @@ -68,11 +68,11 @@ available_setting = { "claude_api_cookie": "", "claude_uuid": "", # 通义千问API, 获取方式查看文档 https://help.aliyun.com/document_detail/2587494.html - "tongyi_access_key_id": "", - "tongyi_access_key_secret": "", - "tongyi_agent_key": "", - "tongyi_app_id": "", - "tongyi_node_id": "", # 流程编排模型用到的id,如果没有用到tongyi_node_id,请务必保持为空字符串 + "qwen_access_key_id": "", + "qwen_access_key_secret": "", + "qwen_agent_key": "", + "qwen_app_id": "", + "qwen_node_id": "", # 流程编排模型用到的id,如果没有用到qwen_node_id,请务必保持为空字符串 # wework的通用配置 "wework_smart": True, # 配置wework是否使用已登录的企业微信,False为多开 # 语音设置