diff --git a/config.py b/config.py
index f25b119..387fab6 100644
--- a/config.py
+++ b/config.py
@@ -83,8 +83,9 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5", "api2d-gpt-3.5-turbo",
- "gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "stack-claude"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
+ "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "api2d-gpt-4",
+ "gpt-4", "gpt-4-32k", "azure-gpt-4", "chatglm", "moss", "newbing", "stack-claude"]
# P.S. 其他可用的模型还包括 ["qianfan", "llama2", "qwen", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613", "gpt-3.5-random"
# "spark", "sparkv2", "chatglm_onnx", "claude-1-100k", "claude-2", "internlm", "jittorllms_pangualpha", "jittorllms_llama"]
@@ -191,6 +192,10 @@ GROBID_URLS = [
ALLOW_RESET_CONFIG = False
+# 在使用AutoGen插件时,是否使用Docker容器运行代码
+AUTOGEN_USE_DOCKER = True
+
+
# 临时的上传文件夹位置,请勿修改
PATH_PRIVATE_UPLOAD = "private_upload"
diff --git a/crazy_functional.py b/crazy_functional.py
index 795bd5f..c11e7cb 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -539,18 +539,18 @@ def get_crazy_functions():
except:
print('Load function plugin failed')
- # try:
- # from crazy_functions.多智能体 import 多智能体终端
- # function_plugins.update({
- # "多智能体终端(微软AutoGen)": {
- # "Group": "智能体",
- # "Color": "stop",
- # "AsButton": True,
- # "Function": HotReload(多智能体终端)
- # }
- # })
- # except:
- # print('Load function plugin failed')
+ try:
+ from crazy_functions.多智能体 import 多智能体终端
+ function_plugins.update({
+ "多智能体终端(微软AutoGen)": {
+ "Group": "智能体",
+ "Color": "stop",
+ "AsButton": True,
+ "Function": HotReload(多智能体终端)
+ }
+ })
+ except:
+ print('Load function plugin failed')
# try:
# from crazy_functions.chatglm微调工具 import 微调数据集生成
diff --git a/crazy_functions/agent_fns/autogen_general.py b/crazy_functions/agent_fns/autogen_general.py
index 18c89ab..beb6d7e 100644
--- a/crazy_functions/agent_fns/autogen_general.py
+++ b/crazy_functions/agent_fns/autogen_general.py
@@ -36,12 +36,8 @@ class AutoGenGeneral(PluginMultiprocessManager):
# ⭐⭐ 子进程执行
input = input.content
with ProxyNetworkActivate("AutoGen"):
- from autogen import AssistantAgent, UserProxyAgent
- config_list = [{
- 'model': self.llm_kwargs['llm_model'],
- 'api_key': self.llm_kwargs['api_key'],
- },]
- code_execution_config={"work_dir": self.autogen_work_dir, "use_docker":True}
+ config_list = self.get_config_list()
+ code_execution_config={"work_dir": self.autogen_work_dir, "use_docker":self.use_docker}
agents = self.define_agents()
user_proxy = None
assistant = None
@@ -67,6 +63,20 @@ class AutoGenGeneral(PluginMultiprocessManager):
tb_str = '```\n' + trimmed_format_exc() + '```'
self.child_conn.send(PipeCom("done", "AutoGen 执行失败: \n\n" + tb_str))
+ def get_config_list(self):
+ model = self.llm_kwargs['llm_model']
+ api_base = None
+ if self.llm_kwargs['llm_model'].startswith('api2d-'):
+ model = self.llm_kwargs['llm_model'][len('api2d-'):]
+ api_base = "https://openai.api2d.net/v1"
+ config_list = [{
+ 'model': model,
+ 'api_key': self.llm_kwargs['api_key'],
+ },]
+ if api_base is not None:
+ config_list[0]['api_base'] = api_base
+ return config_list
+
def subprocess_worker(self, child_conn):
# ⭐⭐ 子进程执行
self.child_conn = child_conn
diff --git a/crazy_functions/agent_fns/pipe.py b/crazy_functions/agent_fns/pipe.py
index d28c5cc..2a0c370 100644
--- a/crazy_functions/agent_fns/pipe.py
+++ b/crazy_functions/agent_fns/pipe.py
@@ -1,4 +1,5 @@
-from toolbox import get_log_folder, update_ui, gen_time_str, trimmed_format_exc, promote_file_to_downloadzone
+from toolbox import get_log_folder, update_ui, gen_time_str, get_conf, promote_file_to_downloadzone
+from crazy_functions.agent_fns.watchdog import WatchDog
import time, os
class PipeCom():
@@ -19,6 +20,16 @@ class PluginMultiprocessManager():
self.system_prompt = system_prompt
self.web_port = web_port
self.alive = True
+ self.use_docker, = get_conf('AUTOGEN_USE_DOCKER')
+
+ # create a thread to monitor self.heartbeat, terminate the instance if no heartbeat for a long time
+ timeout_seconds = 5*60
+ self.heartbeat_watchdog = WatchDog(timeout=timeout_seconds, bark_fn=self.terminate, interval=5)
+ self.heartbeat_watchdog.begin_watch()
+
+ def feed_heartbeat_watchdog(self):
+ # feed this `dog`, so the dog will not `bark` (bark_fn will terminate the instance)
+ self.heartbeat_watchdog.feed()
def is_alive(self):
return self.alive
@@ -50,7 +61,7 @@ class PluginMultiprocessManager():
# 获取fp的拓展名
file_type = fp.split('.')[-1]
# 如果是文本文件, 则直接显示文本内容
- if file_type in ['png', 'jpg']:
+ if file_type.lower() in ['png', 'jpg']:
image_path = os.path.abspath(fp)
self.chatbot.append(['检测到新生图像:', f'本地文件预览: