diff --git a/config.json b/config.json index 86eff0fd..62441154 100644 --- a/config.json +++ b/config.json @@ -310,6 +310,7 @@ "tongyi": { "cookie_path": "cookie/tongyi.json", "type": "api", + "model": "qwen-max", "preset": "你是一个专业的虚拟主播", "api_key": "", "history_enable": true, diff --git a/config.json.bak b/config.json.bak index 86eff0fd..62441154 100644 --- a/config.json.bak +++ b/config.json.bak @@ -310,6 +310,7 @@ "tongyi": { "cookie_path": "cookie/tongyi.json", "type": "api", + "model": "qwen-max", "preset": "你是一个专业的虚拟主播", "api_key": "", "history_enable": true, diff --git a/tests/test_tongyi/tongyi.py b/tests/test_tongyi/tongyi.py index 2cd79792..07768d02 100644 --- a/tests/test_tongyi/tongyi.py +++ b/tests/test_tongyi/tongyi.py @@ -1,6 +1,9 @@ import json, logging, copy import traceback +from utils.common import Common +from utils.logger import Configure_logger + def convert_cookies(cookies: list) -> dict: """转换cookies""" cookies_dict = {} @@ -8,13 +11,12 @@ def convert_cookies(cookies: list) -> dict: cookies_dict[cookie["name"]] = cookie["value"] return cookies_dict - class TongYi: def __init__(self, data): - # self.common = Common() + self.common = Common() # 日志文件路径 - # file_path = "./log/log-" + self.common.get_bj_time(1) + ".txt" - # Configure_logger(file_path) + file_path = "./log/log-" + self.common.get_bj_time(1) + ".txt" + Configure_logger(file_path) self.config_data = data self.cookie_path = data["cookie_path"] @@ -83,7 +85,7 @@ def get_resp(self, prompt): logging.debug(f"messages={messages}") response = Generation.call( - Generation.Models.qwen_max, + self.config_data['model'], messages=messages, result_format='message', # set the result to be "message" format. ) @@ -126,6 +128,7 @@ def get_resp(self, prompt): data = { "cookie_path": 'cookies.json', "type": 'api', + "model": "qwen-max", "preset": "你是一个专业的虚拟主播", "api_key": "sk-", "history_enable": True, diff --git a/utils/gpt_model/tongyi.py b/utils/gpt_model/tongyi.py index e62b1909..07768d02 100644 --- a/utils/gpt_model/tongyi.py +++ b/utils/gpt_model/tongyi.py @@ -85,7 +85,7 @@ def get_resp(self, prompt): logging.debug(f"messages={messages}") response = Generation.call( - Generation.Models.qwen_max, + self.config_data['model'], messages=messages, result_format='message', # set the result to be "message" format. ) @@ -128,6 +128,7 @@ def get_resp(self, prompt): data = { "cookie_path": 'cookies.json', "type": 'api', + "model": "qwen-max", "preset": "你是一个专业的虚拟主播", "api_key": "sk-", "history_enable": True, diff --git a/webui.py b/webui.py index fae43f62..49a561d6 100644 --- a/webui.py +++ b/webui.py @@ -1166,6 +1166,7 @@ def common_textarea_handle(content): config_data["tongyi"]["type"] = select_tongyi_type.value config_data["tongyi"]["cookie_path"] = input_tongyi_cookie_path.value config_data["tongyi"]["api_key"] = input_tongyi_api_key.value + config_data["tongyi"]["model"] = select_tongyi_model.value config_data["tongyi"]["preset"] = input_tongyi_preset.value config_data["tongyi"]["history_enable"] = switch_tongyi_history_enable.value config_data["tongyi"]["history_max_len"] = int(input_tongyi_history_max_len.value) @@ -2789,6 +2790,15 @@ def common_textarea_handle(content): input_tongyi_cookie_path = ui.input(label='cookie路径', placeholder='web类型下,通义千问登录后,通过浏览器插件Cookie Editor获取Cookie JSON串,然后将数据保存在这个路径的文件中', value=config.get("tongyi", "cookie_path")) input_tongyi_cookie_path.style("width:400px") with ui.row(): + lines = ['qwen-turbo', 'qwen-plus', 'qwen-max'] + data_json = {} + for line in lines: + data_json[line] = line + select_tongyi_model = ui.select( + label='类型', + options=data_json, + value=config.get("tongyi", "model") + ).style("width:150px") input_tongyi_api_key = ui.input(label='密钥', value=config.get("tongyi", "api_key"), placeholder='API类型下,DashScope平台申请的API密钥') input_tongyi_preset = ui.input(label='预设', placeholder='API类型下,用于指定一组预定义的设置,以便模型更好地适应特定的对话场景。', value=config.get("tongyi", "preset")).style("width:600px")