Merge branch 'master' into frontier

This commit is contained in:
binary-husky 2024-01-23 15:48:06 +08:00
commit 01def2e329
3 changed files with 33 additions and 35 deletions

View File

@ -35,7 +35,11 @@ def gpt_academic_generate_oai_reply(
class AutoGenGeneral(PluginMultiprocessManager): class AutoGenGeneral(PluginMultiprocessManager):
def gpt_academic_print_override(self, user_proxy, message, sender): def gpt_academic_print_override(self, user_proxy, message, sender):
# ⭐⭐ run in subprocess # ⭐⭐ run in subprocess
self.child_conn.send(PipeCom("show", sender.name + "\n\n---\n\n" + message["content"])) try:
print_msg = sender.name + "\n\n---\n\n" + message["content"]
except:
print_msg = sender.name + "\n\n---\n\n" + message
self.child_conn.send(PipeCom("show", print_msg))
def gpt_academic_get_human_input(self, user_proxy, message): def gpt_academic_get_human_input(self, user_proxy, message):
# ⭐⭐ run in subprocess # ⭐⭐ run in subprocess
@ -62,7 +66,6 @@ class AutoGenGeneral(PluginMultiprocessManager):
def exe_autogen(self, input): def exe_autogen(self, input):
# ⭐⭐ run in subprocess # ⭐⭐ run in subprocess
input = input.content input = input.content
with ProxyNetworkActivate("AutoGen"):
code_execution_config = {"work_dir": self.autogen_work_dir, "use_docker": self.use_docker} code_execution_config = {"work_dir": self.autogen_work_dir, "use_docker": self.use_docker}
agents = self.define_agents() agents = self.define_agents()
user_proxy = None user_proxy = None
@ -85,6 +88,7 @@ class AutoGenGeneral(PluginMultiprocessManager):
if agent_kwargs['name'] == 'assistant': assistant = agent_handle if agent_kwargs['name'] == 'assistant': assistant = agent_handle
try: try:
if user_proxy is None or assistant is None: raise Exception("用户代理或助理代理未定义") if user_proxy is None or assistant is None: raise Exception("用户代理或助理代理未定义")
with ProxyNetworkActivate("AutoGen"):
user_proxy.initiate_chat(assistant, message=input) user_proxy.initiate_chat(assistant, message=input)
except Exception as e: except Exception as e:
tb_str = '```\n' + trimmed_format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'

View File

@ -51,13 +51,6 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
if model_info[llm_kwargs['llm_model']]["endpoint"] is not None: # 如果不是本地模型加载API_KEY if model_info[llm_kwargs['llm_model']]["endpoint"] is not None: # 如果不是本地模型加载API_KEY
llm_kwargs['api_key'] = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model']) llm_kwargs['api_key'] = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
# 检查当前的模型是否符合要求
API_URL_REDIRECT = get_conf('API_URL_REDIRECT')
if len(API_URL_REDIRECT) > 0:
chatbot.append([f"处理任务: {txt}", f"暂不支持中转."])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
# 尝试导入依赖,如果缺少依赖,则给出安装建议 # 尝试导入依赖,如果缺少依赖,则给出安装建议
try: try:
import autogen import autogen

View File

@ -11,6 +11,7 @@ from functools import wraps
from shared_utils.config_loader import get_conf from shared_utils.config_loader import get_conf
from shared_utils.config_loader import set_conf from shared_utils.config_loader import set_conf
from shared_utils.config_loader import set_multi_conf from shared_utils.config_loader import set_multi_conf
from shared_utils.config_loader import read_single_conf_with_lru_cache
from shared_utils.advanced_markdown_format import format_io from shared_utils.advanced_markdown_format import format_io
from shared_utils.advanced_markdown_format import markdown_convertion from shared_utils.advanced_markdown_format import markdown_convertion
from shared_utils.key_pattern_manager import select_api_key from shared_utils.key_pattern_manager import select_api_key