fix workflow bug, disable local LLM temporary.

This commit is contained in:
Liu Zhicong
2023-09-19 00:23:19 -07:00
parent 874aa98e21
commit 56d15fd003
6 changed files with 12 additions and 26 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ class OpenAI_ComputeNode(ComputeNode):
mode_name = task.params["model_name"]
prompts = task.params["prompts"]
max_token_size = task.params.get("max_token_size")
llm_inner_functions = task.params["inner_functions"]
llm_inner_functions = task.params.get("inner_functions")
if max_token_size is None:
max_token_size = 4000
+6 -20
View File
@@ -47,23 +47,18 @@ class TelegramTunnel(AgentTunnel):
super().__init__()
self.is_start = False
self.tg_token = tg_token
#self.bot:Bot = None
#self.update_queue = None
#self.tunnel_id = "tg_tunnel#" + self.app.bot.id
self.bot:Bot = None
self.update_queue = None
async def _do_process_raw_message(self,bot: Bot, update_id: int) -> int:
"""Echo the message the user sent."""
# Request updates after the last update_id
updates = await bot.get_updates(offset=update_id, timeout=10, allowed_updates=Update.ALL_TYPES)
for update in updates:
next_update_id = update.update_id + 1
# your bot can receive updates without messages
# and not all messages contain text
if update.message and update.message.text:
# Reply to the message
#logger.info("Found message %s!", update.message.text)
await self.on_message(update)
await self.on_message(bot,update)
return next_update_id
return update_id
@@ -79,15 +74,8 @@ class TelegramTunnel(AgentTunnel):
self.update_queue = asyncio.Queue()
self.bot_updater = Updater(self.bot,update_queue=self.update_queue)
#self.app:Application = Application.builder().token(self.tg_token).build()
#self.app.add_handler(MessageHandler(filters.TEXT, self.on_message))
async def _run_app():
#loop = asyncio.new_event_loop()
#asyncio.set_event_loop(loop)
#self.app.run_polling(allowed_updates=Update.ALL_TYPES)
try:
update_id = (await self.bot.get_updates())[0].update_id
except IndexError:
@@ -103,8 +91,6 @@ class TelegramTunnel(AgentTunnel):
# The user has removed or blocked the bot.
update_id += 1
#self.poll_thread = threading.Thread(target=_run_app)
#self.poll_thread.start()
asyncio.create_task(_run_app())
logger.warning(f"tunnel {self.tunnel_id} started.")
return True
@@ -129,7 +115,7 @@ class TelegramTunnel(AgentTunnel):
async def on_message(self, update: Update) -> None:
async def on_message(self, bot:Bot, update: Update) -> None:
cm = ContactManager.get_instance()
reomte_user_name = f"{update.effective_user.id}@telegram"
#contact = cm.get_by_name(update.effective_user.username)
@@ -143,7 +129,7 @@ class TelegramTunnel(AgentTunnel):
agent_msg = await self.conver_tg_msg_to_agent_msg(update)
agent_msg.sender = reomte_user_name
self.ai_bus.register_message_handler(reomte_user_name, self._process_message)
#await context.bot.send_chat_action(chat_id=update.effective_chat.id, action="thinking")
#await bot.send_chat_action(chat_id=update.effective_chat.id, action="typing")
resp_msg = await self.ai_bus.send_message(agent_msg)
logger.info(f"process message {agent_msg.msg_id} from {agent_msg.sender} to {agent_msg.target}")
if resp_msg is None:
+1 -1
View File
@@ -126,7 +126,7 @@ class Workflow:
if env_id is None:
continue
remote_env = Environment.get_env_by_id(_node.get(env_id))
remote_env = Environment.get_env_by_id(env_id)
if remote_env is None:
logger.error(f"Workflow load connected_env failed, env {env_id} not found!")
return False
+1 -1
View File
@@ -58,7 +58,7 @@ class CalenderEnvironment(Environment):
def stop(self):
self.is_run = False
def get_now(self,key:str)->str:
def get_now(self)->str:
now = datetime.now()
formatted_time = now.strftime('%Y-%m-%d %H:%M:%S')
return formatted_time