Skip to content

Commit

Permalink
后置部分GPT_MODEL配置,规避一次性全加载问题;修复 LLM部分GUI板块显隐bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Aug 17, 2023
1 parent 4925f4d commit 3398b61
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,10 @@ cmd运行`npm i docsify-cli -g`
- 美化logo
- 简单的初步美化下GUI

### 2023-08-18
- 后置部分GPT_MODEL配置,规避一次性全加载问题
- 修复 LLM部分GUI板块显隐bug

</details>


Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2729,7 +2729,7 @@ def oncomboBox_chat_type_IndexChanged(self, index):
7: (0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0),
8: (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0),
9: (0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
9: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
10: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
}

visibility_values = visibility_map.get(index, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
Expand Down
3 changes: 2 additions & 1 deletion utils/gpt_model/claude2.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def send_message(self, prompt, conversation_id, attachment=None):
completions = []
for data_string in data_strings:
json_str = data_string[6:].strip()
logging.debug(f"json_str={json_str}")
data = json.loads(json_str)
if 'completion' in data:
completions.append(data['completion'])
Expand Down Expand Up @@ -344,7 +345,7 @@ def get_claude2_resp(self, prompt):
resp_content = self.send_message(prompt, self.conversation_id)
return resp_content
except Exception as e:
logging.info(e)
logging.error(traceback.format_exc())
return None


Expand Down
19 changes: 12 additions & 7 deletions utils/my_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ def __init__(self, config_path):
# 设置GPT_Model全局模型列表
GPT_MODEL.set_model_config("openai", self.openai_config)
GPT_MODEL.set_model_config("chatgpt", self.chatgpt_config)
GPT_MODEL.set_model_config("claude", self.claude_config)
GPT_MODEL.set_model_config("claude2", self.claude2_config)
GPT_MODEL.set_model_config("chatglm", self.chatglm_config)
GPT_MODEL.set_model_config("text_generation_webui", self.text_generation_webui_config)
GPT_MODEL.set_model_config("sparkdesk", self.sparkdesk_config)
GPT_MODEL.set_model_config("langchain_chatglm", self.langchain_chatglm_config)
GPT_MODEL.set_model_config("claude", self.claude_config)

self.chatgpt = None
self.claude = None
Expand All @@ -140,6 +135,8 @@ def __init__(self, config_path):
if not self.claude.reset_claude():
logging.error("重置Claude会话失败喵~")
elif self.chat_type == "claude2":
GPT_MODEL.set_model_config("claude2", self.claude2_config)

self.claude2 = GPT_MODEL.get(self.chat_type)

# 初次运行 先重置下会话
Expand All @@ -156,15 +153,23 @@ def __init__(self, config_path):
logging.info(e)
exit(0)
elif self.chat_type == "chatglm":
GPT_MODEL.set_model_config("chatglm", self.chatglm_config)

self.chatglm = GPT_MODEL.get(self.chat_type)
elif self.chat_type == "chat_with_file":
from utils.chat_with_file.chat_with_file import Chat_with_file
self.chat_with_file = Chat_with_file(self.chat_with_file_config)
elif self.chat_type == "text_generation_webui":
GPT_MODEL.set_model_config("text_generation_webui", self.text_generation_webui_config)

self.text_generation_webui = GPT_MODEL.get(self.chat_type)
elif self.chat_type == "sparkdesk":
GPT_MODEL.set_model_config("sparkdesk", self.sparkdesk_config)

self.sparkdesk = GPT_MODEL.get(self.chat_type)
elif self.chat_type == "langchain_chatglm":
GPT_MODEL.set_model_config("langchain_chatglm", self.langchain_chatglm_config)

self.langchain_chatglm = GPT_MODEL.get(self.chat_type)
elif self.chat_type == "game":
# from game.game import Game
Expand Down Expand Up @@ -843,7 +848,7 @@ def comment_handle(self, data):
logging.info(f"[AI回复{user_name}]:{resp_content}")
else:
resp_content = ""
logging.warning("警告:claude无返回")
logging.warning("警告:claude2无返回")
elif self.chat_type == "chatterbot":
# 生成回复
resp_content = self.bot.get_response(content).text
Expand Down

0 comments on commit 3398b61

Please sign in to comment.