From e6716ccf630564a728cc158e4660db898f109c9b Mon Sep 17 00:00:00 2001 From: binary-husky Date: Fri, 24 Nov 2023 01:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0zhipuai=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 4 ++++ request_llms/bridge_zhipu.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/config.py b/config.py index ea603c3..baaaaa8 100644 --- a/config.py +++ b/config.py @@ -271,6 +271,10 @@ NUM_CUSTOM_BASIC_BTN = 4 │ ├── BAIDU_CLOUD_API_KEY │ └── BAIDU_CLOUD_SECRET_KEY │ +├── "zhipuai" 智谱AI大模型chatglm_turbo +│ ├── ZHIPUAI_API_KEY +│ └── ZHIPUAI_MODEL +│ ├── "newbing" Newbing接口不再稳定,不推荐使用 ├── NEWBING_STYLE └── NEWBING_COOKIES diff --git a/request_llms/bridge_zhipu.py b/request_llms/bridge_zhipu.py index a1e0de5..915a13e 100644 --- a/request_llms/bridge_zhipu.py +++ b/request_llms/bridge_zhipu.py @@ -1,6 +1,7 @@ import time from toolbox import update_ui, get_conf, update_ui_lastest_msg +from toolbox import check_packages, report_exception model_name = '智谱AI大模型' @@ -37,6 +38,14 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp chatbot.append((inputs, "")) 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: yield from update_ui_lastest_msg(lastmsg="[Local Message] 请配置ZHIPUAI_API_KEY", chatbot=chatbot, history=history, delay=0) return