Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add error information #145

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from chatllm import ChatLLM
from chinese_text_splitter import ChineseTextSplitter
from config import *
import torch

nltk.data.path = [os.path.join(os.path.dirname(__file__), "nltk_data")
] + nltk.data.path
Expand Down Expand Up @@ -68,6 +69,8 @@ def init_model_config(
device=EMBEDDING_DEVICE,
cache_folder=os.path.join(MODEL_CACHE_PATH,
self.embeddings.model_name))
self.llm = None
torch.cuda.empty_cache()
self.llm = ChatLLM()
if 'chatglm2' in large_language_model.lower():
self.llm.model_type = 'chatglm2'
Expand Down Expand Up @@ -170,17 +173,17 @@ def update_status(history, status):

knowladge_based_chat_llm = KnowledgeBasedChatLLM()


def init_model():
try:
print("开始加载模型配置")
knowladge_based_chat_llm.init_model_config()
print("模型配置加载成功")
knowladge_based_chat_llm.llm._call("你好")
return """初始模型已成功加载,可以开始对话"""
except Exception as e:

print(f"加载模型出错: {e}") # 打印详细的异常信息
return """模型未成功加载,请重新选择模型后点击"重新加载模型"按钮"""


def clear_session():
return '', None

Expand Down