Skip to content

Commit

Permalink
补充通义千问遗漏的模型配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Mar 1, 2024
1 parent dc79179 commit ea039f1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
"tongyi": {
"cookie_path": "cookie/tongyi.json",
"type": "api",
"model": "qwen-max",
"preset": "你是一个专业的虚拟主播",
"api_key": "",
"history_enable": true,
Expand Down
1 change: 1 addition & 0 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
"tongyi": {
"cookie_path": "cookie/tongyi.json",
"type": "api",
"model": "qwen-max",
"preset": "你是一个专业的虚拟主播",
"api_key": "",
"history_enable": true,
Expand Down
13 changes: 8 additions & 5 deletions tests/test_tongyi/tongyi.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
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 = {}
for cookie in cookies:
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"]
Expand Down Expand Up @@ -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.
)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion utils/gpt_model/tongyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
)
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit ea039f1

Please sign in to comment.