添加zhipuai依赖安装提醒

This commit is contained in:
binary-husky 2023-11-24 01:47:03 +08:00
parent e533ed6d12
commit e6716ccf63
2 changed files with 13 additions and 0 deletions

View File

@ -271,6 +271,10 @@ NUM_CUSTOM_BASIC_BTN = 4
BAIDU_CLOUD_API_KEY BAIDU_CLOUD_API_KEY
BAIDU_CLOUD_SECRET_KEY BAIDU_CLOUD_SECRET_KEY
"zhipuai" 智谱AI大模型chatglm_turbo
ZHIPUAI_API_KEY
ZHIPUAI_MODEL
"newbing" Newbing接口不再稳定不推荐使用 "newbing" Newbing接口不再稳定不推荐使用
NEWBING_STYLE NEWBING_STYLE
NEWBING_COOKIES NEWBING_COOKIES

View File

@ -1,6 +1,7 @@
import time import time
from toolbox import update_ui, get_conf, update_ui_lastest_msg from toolbox import update_ui, get_conf, update_ui_lastest_msg
from toolbox import check_packages, report_exception
model_name = '智谱AI大模型' model_name = '智谱AI大模型'
@ -37,6 +38,14 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
chatbot.append((inputs, "")) chatbot.append((inputs, ""))
yield from update_ui(chatbot=chatbot, history=history) yield from update_ui(chatbot=chatbot, history=history)
# 尝试导入依赖,如果缺少依赖,则给出安装建议
try:
check_packages(["zhipuai"])
except:
yield from update_ui_lastest_msg(f"导入软件依赖失败。使用该模型需要额外依赖,安装方法```pip install --upgrade zhipuai```。",
chatbot=chatbot, history=history, delay=0)
return
if validate_key() is False: if validate_key() is False:
yield from update_ui_lastest_msg(lastmsg="[Local Message] 请配置ZHIPUAI_API_KEY", chatbot=chatbot, history=history, delay=0) yield from update_ui_lastest_msg(lastmsg="[Local Message] 请配置ZHIPUAI_API_KEY", chatbot=chatbot, history=history, delay=0)
return return