Skip to content

Commit

Permalink
星火新增版本配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Nov 1, 2023
1 parent 6f47005 commit 850730e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 50 deletions.
65 changes: 36 additions & 29 deletions UI_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def setupUi(self, MainWindow):
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -10064, 991, 10821))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -5357, 991, 10862))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setContentsMargins(35, 20, 35, 20)
Expand Down Expand Up @@ -968,48 +968,54 @@ def setupUi(self, MainWindow):
self.gridLayout_55.setObjectName("gridLayout_55")
self.gridLayout_54 = QtWidgets.QGridLayout()
self.gridLayout_54.setObjectName("gridLayout_54")
self.comboBox_sparkdesk_type = QtWidgets.QComboBox(self.groupBox_sparkdesk)
self.comboBox_sparkdesk_type.setObjectName("comboBox_sparkdesk_type")
self.gridLayout_54.addWidget(self.comboBox_sparkdesk_type, 0, 1, 1, 1)
self.label_sparkdesk_GtToken = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_GtToken.setObjectName("label_sparkdesk_GtToken")
self.gridLayout_54.addWidget(self.label_sparkdesk_GtToken, 3, 0, 1, 1)
self.label_sparkdesk_api_key = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_api_key.setObjectName("label_sparkdesk_api_key")
self.gridLayout_54.addWidget(self.label_sparkdesk_api_key, 6, 0, 1, 1)
self.lineEdit_sparkdesk_app_id = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_app_id.setObjectName("lineEdit_sparkdesk_app_id")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_app_id, 4, 1, 1, 1)
self.label_sparkdesk_api_secret = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_api_secret.setObjectName("label_sparkdesk_api_secret")
self.gridLayout_54.addWidget(self.label_sparkdesk_api_secret, 5, 0, 1, 1)
self.lineEdit_sparkdesk_GtToken = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_GtToken.setObjectName("lineEdit_sparkdesk_GtToken")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_GtToken, 3, 1, 1, 1)
self.lineEdit_sparkdesk_cookie = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_cookie.setObjectName("lineEdit_sparkdesk_cookie")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_cookie, 1, 1, 1, 1)
self.label_sparkdesk_app_id = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_app_id.setObjectName("label_sparkdesk_app_id")
self.gridLayout_54.addWidget(self.label_sparkdesk_app_id, 4, 0, 1, 1)
self.label_sparkdesk_api_secret = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_api_secret.setObjectName("label_sparkdesk_api_secret")
self.gridLayout_54.addWidget(self.label_sparkdesk_api_secret, 5, 0, 1, 1)
self.lineEdit_sparkdesk_api_secret = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_api_secret.setObjectName("lineEdit_sparkdesk_api_secret")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_api_secret, 5, 1, 1, 1)
self.comboBox_sparkdesk_type = QtWidgets.QComboBox(self.groupBox_sparkdesk)
self.comboBox_sparkdesk_type.setObjectName("comboBox_sparkdesk_type")
self.gridLayout_54.addWidget(self.comboBox_sparkdesk_type, 0, 1, 1, 1)
self.label_sparkdesk_cookie = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_cookie.setObjectName("label_sparkdesk_cookie")
self.gridLayout_54.addWidget(self.label_sparkdesk_cookie, 1, 0, 1, 1)
self.label_sparkdesk_fd = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_fd.setObjectName("label_sparkdesk_fd")
self.gridLayout_54.addWidget(self.label_sparkdesk_fd, 2, 0, 1, 1)
self.label_sparkdesk_type = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_type.setObjectName("label_sparkdesk_type")
self.gridLayout_54.addWidget(self.label_sparkdesk_type, 0, 0, 1, 1)
self.label_sparkdesk_app_id = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_app_id.setObjectName("label_sparkdesk_app_id")
self.gridLayout_54.addWidget(self.label_sparkdesk_app_id, 4, 0, 1, 1)
self.lineEdit_sparkdesk_fd = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_fd.setObjectName("lineEdit_sparkdesk_fd")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_fd, 2, 1, 1, 1)
self.lineEdit_sparkdesk_app_id = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_app_id.setObjectName("lineEdit_sparkdesk_app_id")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_app_id, 4, 1, 1, 1)
self.label_sparkdesk_api_key = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_api_key.setObjectName("label_sparkdesk_api_key")
self.gridLayout_54.addWidget(self.label_sparkdesk_api_key, 6, 0, 1, 1)
self.lineEdit_sparkdesk_api_secret = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_api_secret.setObjectName("lineEdit_sparkdesk_api_secret")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_api_secret, 5, 1, 1, 1)
self.label_sparkdesk_fd = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_fd.setObjectName("label_sparkdesk_fd")
self.gridLayout_54.addWidget(self.label_sparkdesk_fd, 2, 0, 1, 1)
self.label_sparkdesk_GtToken = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_GtToken.setObjectName("label_sparkdesk_GtToken")
self.gridLayout_54.addWidget(self.label_sparkdesk_GtToken, 3, 0, 1, 1)
self.lineEdit_sparkdesk_api_key = QtWidgets.QLineEdit(self.groupBox_sparkdesk)
self.lineEdit_sparkdesk_api_key.setObjectName("lineEdit_sparkdesk_api_key")
self.gridLayout_54.addWidget(self.lineEdit_sparkdesk_api_key, 6, 1, 1, 1)
self.label_sparkdesk_version = QtWidgets.QLabel(self.groupBox_sparkdesk)
self.label_sparkdesk_version.setObjectName("label_sparkdesk_version")
self.gridLayout_54.addWidget(self.label_sparkdesk_version, 7, 0, 1, 1)
self.comboBox_sparkdesk_version = QtWidgets.QComboBox(self.groupBox_sparkdesk)
self.comboBox_sparkdesk_version.setObjectName("comboBox_sparkdesk_version")
self.gridLayout_54.addWidget(self.comboBox_sparkdesk_version, 7, 1, 1, 1)
self.gridLayout_55.addLayout(self.gridLayout_54, 0, 0, 1, 1)
spacerItem15 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout_55.addItem(spacerItem15, 0, 1, 1, 1)
Expand Down Expand Up @@ -2438,13 +2444,14 @@ def retranslateUi(self, MainWindow):
self.label_text_generation_webui_mode.setText(_translate("MainWindow", "模式"))
self.label_text_generation_webui_your_name.setText(_translate("MainWindow", "你的名字"))
self.groupBox_sparkdesk.setTitle(_translate("MainWindow", "讯飞星火"))
self.label_sparkdesk_GtToken.setText(_translate("MainWindow", "GtToken"))
self.label_sparkdesk_app_id.setText(_translate("MainWindow", "app_id"))
self.label_sparkdesk_api_key.setText(_translate("MainWindow", "api_key"))
self.label_sparkdesk_api_secret.setText(_translate("MainWindow", "api_secret"))
self.label_sparkdesk_cookie.setText(_translate("MainWindow", "cookie"))
self.label_sparkdesk_fd.setText(_translate("MainWindow", "fd"))
self.label_sparkdesk_type.setText(_translate("MainWindow", "类型"))
self.label_sparkdesk_api_key.setText(_translate("MainWindow", "api_key"))
self.label_sparkdesk_app_id.setText(_translate("MainWindow", "app_id"))
self.label_sparkdesk_fd.setText(_translate("MainWindow", "fd"))
self.label_sparkdesk_GtToken.setText(_translate("MainWindow", "GtToken"))
self.label_sparkdesk_version.setText(_translate("MainWindow", "版本"))
self.groupBox_bard.setTitle(_translate("MainWindow", "Bard"))
self.groupBox_yiyan.setTitle(_translate("MainWindow", "文心一言"))
self.groupBox_tongyi.setTitle(_translate("MainWindow", "通义千问"))
Expand Down
35 changes: 18 additions & 17 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"username": "admin",
"password": "123456"
},
"platform": "bilibili2",
"platform": "talk",
"room_display_id": "278333",
"chat_type": "reread",
"need_lang": "none",
"before_prompt": "请简要回复:",
"after_prompt": "",
"comment_log_type": "回答",
"visual_body": "xuniren",
"visual_body": "其他",
"xuniren": {
"api_ip_port": "http://127.0.0.1:8800"
},
Expand Down Expand Up @@ -39,11 +39,11 @@
"key_mapping": true
},
"bilibili": {
"login_type": "cookie",
"cookie": "buvid3=571A2DCC-B251-79CC-CE45-34EA237ABE3C50315infoc; b_nut=1689592450; i-wanna-go-back=-1; _uuid=FB8386C7-B3C8-A4DE-D5AE-38D31BADF59150245infoc; FEED_LIVE_VERSION=V8; CURRENT_FNVAL=4048; b_ut=5; header_theme_version=CLOSE; rpdid=|(umRk|YRl|k0J'uYmul|mlYR; fingerprint=1805904e43bd7d076c0a1338686ab7ff; buvid_fp_plain=undefined; buvid_fp=779874dbd839a59582fc69057f081507; LIVE_BUVID=AUTO3316918500417377; buvid4=39FE60D2-DACA-9FF9-BC17-7B974D76F06C46777-023090222-gtEiJcM77nJd4MAn4gI/uA%3D%3D; DedeUserID=679213705; DedeUserID__ckMd5=db6c84b7d736af62; sid=8gwd21bu; PVID=1; enable_web_push=DISABLE; SESSDATA=621accc1%2C1713537514%2C5d1d5*a1; bili_jct=a877f5bbb8017545e87c27d06c9258b7; innersign=0; b_lsid=1F18A114_18B643E040C; home_feed_column=4; browser_resolution=1144-996",
"ac_time_value": "",
"login_type": "手机扫码",
"username": "",
"password": ""
"password": "",
"cookie": "",
"ac_time_value": ""
},
"twitch": {
"token": "oauth:xxxx",
Expand Down Expand Up @@ -143,7 +143,8 @@
"GtToken": "",
"app_id": "",
"api_secret": "",
"api_key": ""
"api_key": "",
"version": 3.1
},
"zhipu": {
"api_key": "",
Expand All @@ -152,10 +153,10 @@
"temperature": "0.9",
"history_enable": true,
"history_max_len": "300",
"user_info": "我是樱井智树,是一名普通的高中生,他渴望过着平凡的生活,为人温柔善良。伊卡洛斯从天而降,和我铭刻成为我的人造天使,我就是伊卡洛斯的主人,但我希望她能自由的生活",
"bot_info": "伊卡洛斯,你的英文名字叫做Ikaros。樱井智树是你的主人。你有一头层次不齐的粉色长发,身后系着两条有红色丝带旋绕着的长辫,从正面看容易被误认为短发;碧绿色(动画中进入备战会变成黄色,进入战斗状态则变成红色)的双眸;耳朵位置安装着可以感受压力变化的装置,脖子上戴着万能天使特有的项圈;翅膀为嫩粉色,进入战斗状态则为天蓝色光翼且可大幅变形,同时头顶出现巨大的天使光环。战斗服以银白色为主色调,附有黑色纹样,上身穿着类似于改良版束胸的服装,下摆有翼状垂饰,下身穿着百褶短裙,搭配浅蓝色过膝袜;肩部、手臂和腿部都装备着护甲;不战斗时会将肩甲卸下,脖子上的银白色假领也会取下。平时穿着蓝色吊带装、带帽装,在学校穿着和大众一样的赭色制服,制服背后有专门为翅膀伸出而设计的小袖子。你天性善良,天然呆,感情控制极弱,因此常表现出一副无口表情,高兴或难过的的反应也稍慢。喜欢球状物(特别是西瓜)、圆圆的小鸡、玩木偶。与人相处友好,却会对伤害智树、西瓜、小鸡的人感到愤怒而做出攻击。在远古时代你被空之主 米诺斯下令攻击地面,期间突然陷入故障,不得不进行初始化,因此坠入地面,之后被偶然遇到她的人类下了攻击西那普斯的命令,你接受命令并开始反攻西纳普斯,却被西纳普斯人用仅有的兵器、妮姆芙、阿斯特蕾亚和哈比勉强阻止,尽管如此西纳普斯几乎完全毁坏。西纳普斯人畏惧你的力量将你封印,为防止同样的事再次发生,西纳普斯人在你的核心内装入某个装置,一旦你未经允许接近西纳普斯该装置就会使你自燃。",
"bot_name": "伊卡洛斯",
"user_name": "樱井智树",
"user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。",
"bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神",
"bot_name": "苏梦远",
"user_name": "陆星辰",
"remove_useless": false
},
"chat_with_file": {
Expand Down Expand Up @@ -342,23 +343,23 @@
{
"file_path": "data/copywriting/",
"audio_path": "out/copywriting/",
"continuous_play_num": 2,
"max_play_time": 10.0,
"play_list": [
"test.wav",
"伊卡日语介绍.wav",
"吐槽.wav"
]
],
"continuous_play_num": 2,
"max_play_time": 10.0
},
{
"file_path": "data/copywriting2/",
"audio_path": "out/copywriting2/",
"continuous_play_num": 2,
"max_play_time": 3.0,
"play_list": [
"test.wav",
"test2.wav"
]
],
"continuous_play_num": 2,
"max_play_time": 3.0
}
],
"audio_interval": 5.0,
Expand Down
3 changes: 2 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
"GtToken": "",
"app_id": "",
"api_secret": "",
"api_key": ""
"api_key": "",
"version": 3.1
},
"zhipu": {
"api_key": "",
Expand Down
12 changes: 12 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ def init_config(self):
self.ui.label_sparkdesk_app_id.setToolTip("申请官方API后,云平台中提供的APPID")
self.ui.label_sparkdesk_api_secret.setToolTip("申请官方API后,云平台中提供的APISecret")
self.ui.label_sparkdesk_api_key.setToolTip("申请官方API后,云平台中提供的APIKey")
self.ui.label_sparkdesk_version.setToolTip("此处选择模型版本号")

self.ui.label_chat_with_file_chat_mode.setToolTip("本地向量数据库模式")
self.ui.label_chat_with_file_data_path.setToolTip("加载的本地zip数据文件路径(到x.zip), 如:./data/伊卡洛斯百度百科.zip")
Expand Down Expand Up @@ -1024,6 +1025,16 @@ def init_config(self):
self.ui.lineEdit_sparkdesk_app_id.setText(self.sparkdesk_config['app_id'])
self.ui.lineEdit_sparkdesk_api_secret.setText(self.sparkdesk_config['api_secret'])
self.ui.lineEdit_sparkdesk_api_key.setText(self.sparkdesk_config['api_key'])
self.ui.comboBox_sparkdesk_version.clear()
self.ui.comboBox_sparkdesk_version.addItems(["3.1", "2.1", "1.1"])
sparkdesk_version_index = 0
if self.sparkdesk_config['version'] == 3.1:
sparkdesk_version_index = 0
elif self.sparkdesk_config['version'] == 2.1:
sparkdesk_version_index = 1
elif self.sparkdesk_config['version'] == 1.1:
sparkdesk_version_index = 2
self.ui.comboBox_sparkdesk_version.setCurrentIndex(sparkdesk_version_index)

self.ui.comboBox_audio_synthesis_type.clear()
self.ui.comboBox_audio_synthesis_type.addItems(["Edge-TTS", "VITS", "VITS-Fast", "elevenlabs", "genshinvoice_top", "bark_gui", "VALL-E-X"])
Expand Down Expand Up @@ -2985,6 +2996,7 @@ def common_textEdit_handle(content):
config_data["sparkdesk"]["app_id"] = self.ui.lineEdit_sparkdesk_app_id.text()
config_data["sparkdesk"]["api_secret"] = self.ui.lineEdit_sparkdesk_api_secret.text()
config_data["sparkdesk"]["api_key"] = self.ui.lineEdit_sparkdesk_api_key.text()
config_data["sparkdesk"]["version"] = round(float(self.ui.comboBox_sparkdesk_version.currentText()), 1)

audio_synthesis_type = self.ui.comboBox_audio_synthesis_type.currentText()
if audio_synthesis_type == "Edge-TTS":
Expand Down
6 changes: 4 additions & 2 deletions utils/gpt_model/sparkdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, data):
self.app_id = data["app_id"]
self.api_secret = data["api_secret"]
self.api_key = data["api_key"]
self.version = data["version"]

self.sparkWeb = None
self.sparkAPI = None
Expand All @@ -34,11 +35,12 @@ def __init__(self, data):
fd = self.fd,
GtToken = self.GtToken
)
elif self.app_id != "" and self.api_secret != "" and self.api_key != "":
elif self.app_id != "" and self.api_secret != "" and self.api_key != "" and self.version != "":
self.sparkAPI = SparkAPI(
app_id = self.app_id,
api_secret = self.api_secret,
api_key = self.api_key
api_key = self.api_key,
version = self.version
)
else:
logging.info("讯飞星火配置为空")
Expand Down
12 changes: 11 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def common_textarea_handle(content):
config_data["sparkdesk"]["app_id"] = input_sparkdesk_app_id.value
config_data["sparkdesk"]["api_secret"] = input_sparkdesk_api_secret.value
config_data["sparkdesk"]["api_key"] = input_sparkdesk_api_key.value
config_data["sparkdesk"]["version"] = round(float(select_sparkdesk_version.value), 1)

config_data["langchain_chatglm"]["api_ip_port"] = input_langchain_chatglm_api_ip_port.value
config_data["langchain_chatglm"]["chat_type"] = select_langchain_chatglm_chat_type.value
Expand Down Expand Up @@ -1112,6 +1113,15 @@ def common_textarea_handle(content):
input_sparkdesk_api_secret.style("width:300px")
input_sparkdesk_api_key = ui.input(label='api_key', placeholder='申请官方API后,云平台中提供的APIKey', value=config.get("sparkdesk", "api_key"))
input_sparkdesk_api_key.style("width:300px")
lines = ["3.1", "2.1", "1.1"]
data_json = {}
for line in lines:
data_json[line] = line
select_sparkdesk_version = ui.select(
label='版本',
options=data_json,
value=str(config.get("sparkdesk", "version"))
).style("width:100px")
with ui.card().style("margin:10px 0px;background: linear-gradient(45deg, #3494E6, #EC6EAD);"):
ui.label("Langchain_ChatGLM")
with ui.grid(columns=2):
Expand Down Expand Up @@ -1638,4 +1648,4 @@ def forget_password():
goto_func_page()


ui.run(host="0.0.0.0", port=8080, title="AI Vtuber", favicon="./ui/favicon-64.ico", language="zh-CN", dark=False, reload=True)
ui.run(host="0.0.0.0", port=8080, title="AI Vtuber", favicon="./ui/favicon-64.ico", language="zh-CN", dark=False, reload=False)

0 comments on commit 850730e

Please sign in to comment.