处理模型兼容的一些细节

This commit is contained in:
qingxu fu 2023-11-11 22:35:06 +08:00
parent a655ce1f00
commit f7f6db831b
4 changed files with 19 additions and 4 deletions

View File

@ -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):

View File

@ -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):

View File

@ -48,10 +48,12 @@ 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
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'])
# 检查当前的模型是否符合要求

View File

@ -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