From f7f6db831beb891a9b5daa291db9136c1ef11dc2 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Sat, 11 Nov 2023 22:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=A8=A1=E5=9E=8B=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E7=9A=84=E4=B8=80=E4=BA=9B=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/agent_fns/general.py | 1 + crazy_functions/agent_fns/pipe.py | 7 ++++++- crazy_functions/多智能体.py | 8 +++++--- request_llms/bridge_all.py | 7 +++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/crazy_functions/agent_fns/general.py b/crazy_functions/agent_fns/general.py index 8b2884d..49bc4dc 100644 --- a/crazy_functions/agent_fns/general.py +++ b/crazy_functions/agent_fns/general.py @@ -29,6 +29,7 @@ def gpt_academic_generate_oai_reply( sys_prompt=self._oai_system_message[0]['content'], console_slience=True ) + assumed_done = reply.endswith('\nTERMINATE') return True, reply class AutoGenGeneral(PluginMultiprocessManager): diff --git a/crazy_functions/agent_fns/pipe.py b/crazy_functions/agent_fns/pipe.py index 680e91c..6ce9961 100644 --- a/crazy_functions/agent_fns/pipe.py +++ b/crazy_functions/agent_fns/pipe.py @@ -21,7 +21,7 @@ class PluginMultiprocessManager: # self.web_port = web_port self.alive = True self.use_docker = get_conf("AUTOGEN_USE_DOCKER") - + self.last_user_input = "" # 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) @@ -55,6 +55,11 @@ class PluginMultiprocessManager: def send_command(self, cmd): # ⭐ run in main process + if cmd == self.last_user_input: + print('repeated input detected, ignore') + cmd = "" + else: + self.last_user_input = cmd self.parent_conn.send(PipeCom("user_input", cmd)) def immediate_showoff_when_possible(self, fp): diff --git a/crazy_functions/多智能体.py b/crazy_functions/多智能体.py index 590c638..8b9a69c 100644 --- a/crazy_functions/多智能体.py +++ b/crazy_functions/多智能体.py @@ -48,11 +48,13 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_ "azure-gpt-4", "azure-gpt-4-32k", ] - if llm_kwargs['llm_model'] not in supported_llms: - chatbot.append([f"处理任务: {txt}", f"当前插件只支持{str(supported_llms)}, 当前模型{llm_kwargs['llm_model']}."]) + from request_llms.bridge_all import model_info + if model_info[llm_kwargs['llm_model']]["max_token"] < 8000: # 至少是8k上下文的模型 + chatbot.append([f"处理任务: {txt}", f"当前插件只支持{str(supported_llms)}, 当前模型{llm_kwargs['llm_model']}的最大上下文长度太短, 不能支撑AutoGen运行。"]) yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 return - llm_kwargs['api_key'] = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model']) + 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']) # 检查当前的模型是否符合要求 API_URL_REDIRECT = get_conf('API_URL_REDIRECT') diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index 646e7a6..7d13bbd 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -242,6 +242,13 @@ for model in AVAIL_LLM_MODELS: mi.update({"endpoint": api2d_endpoint}) model_info.update({model: mi}) +# -=-=-=-=-=-=- azure 对齐支持 -=-=-=-=-=-=- +for model in AVAIL_LLM_MODELS: + if model.startswith('azure-') and (model.replace('azure-','') in model_info.keys()): + mi = model_info[model.replace('azure-','')] + mi.update({"endpoint": azure_endpoint}) + model_info.update({model: mi}) + # -=-=-=-=-=-=- 以下部分是新加入的模型,可能附带额外依赖 -=-=-=-=-=-=- if "claude-1-100k" in AVAIL_LLM_MODELS or "claude-2" in AVAIL_LLM_MODELS: from .bridge_claude import predict_no_ui_long_connection as claude_noui