处理模型兼容的一些细节
This commit is contained in:
parent
a655ce1f00
commit
f7f6db831b
@ -29,6 +29,7 @@ def gpt_academic_generate_oai_reply(
|
|||||||
sys_prompt=self._oai_system_message[0]['content'],
|
sys_prompt=self._oai_system_message[0]['content'],
|
||||||
console_slience=True
|
console_slience=True
|
||||||
)
|
)
|
||||||
|
assumed_done = reply.endswith('\nTERMINATE')
|
||||||
return True, reply
|
return True, reply
|
||||||
|
|
||||||
class AutoGenGeneral(PluginMultiprocessManager):
|
class AutoGenGeneral(PluginMultiprocessManager):
|
||||||
|
@ -21,7 +21,7 @@ class PluginMultiprocessManager:
|
|||||||
# self.web_port = web_port
|
# self.web_port = web_port
|
||||||
self.alive = True
|
self.alive = True
|
||||||
self.use_docker = get_conf("AUTOGEN_USE_DOCKER")
|
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
|
# create a thread to monitor self.heartbeat, terminate the instance if no heartbeat for a long time
|
||||||
timeout_seconds = 5 * 60
|
timeout_seconds = 5 * 60
|
||||||
self.heartbeat_watchdog = WatchDog(timeout=timeout_seconds, bark_fn=self.terminate, interval=5)
|
self.heartbeat_watchdog = WatchDog(timeout=timeout_seconds, bark_fn=self.terminate, interval=5)
|
||||||
@ -55,6 +55,11 @@ class PluginMultiprocessManager:
|
|||||||
|
|
||||||
def send_command(self, cmd):
|
def send_command(self, cmd):
|
||||||
# ⭐ run in main process
|
# ⭐ 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))
|
self.parent_conn.send(PipeCom("user_input", cmd))
|
||||||
|
|
||||||
def immediate_showoff_when_possible(self, fp):
|
def immediate_showoff_when_possible(self, fp):
|
||||||
|
@ -48,11 +48,13 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
|
|||||||
"azure-gpt-4",
|
"azure-gpt-4",
|
||||||
"azure-gpt-4-32k",
|
"azure-gpt-4-32k",
|
||||||
]
|
]
|
||||||
if llm_kwargs['llm_model'] not in supported_llms:
|
from request_llms.bridge_all import model_info
|
||||||
chatbot.append([f"处理任务: {txt}", f"当前插件只支持{str(supported_llms)}, 当前模型{llm_kwargs['llm_model']}."])
|
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) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
return
|
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')
|
API_URL_REDIRECT = get_conf('API_URL_REDIRECT')
|
||||||
|
@ -242,6 +242,13 @@ for model in AVAIL_LLM_MODELS:
|
|||||||
mi.update({"endpoint": api2d_endpoint})
|
mi.update({"endpoint": api2d_endpoint})
|
||||||
model_info.update({model: mi})
|
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:
|
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
|
from .bridge_claude import predict_no_ui_long_connection as claude_noui
|
||||||
|
Loading…
x
Reference in New Issue
Block a user