浏览代码

Update push_service: configurable max workers and fetch dialogue from db

StrayWarrior 4 周之前
父节点
当前提交
d071999757
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      pqai_agent/push_service.py

+ 5 - 2
pqai_agent/push_service.py

@@ -71,7 +71,8 @@ class PushTaskWorkerPool:
     def __init__(self, agent_service: 'AgentService', mq_topic: str,
                  mq_consumer: rocketmq.SimpleConsumer, mq_producer: rocketmq.Producer):
         self.agent_service = agent_service
-        self.generate_executor = ThreadPoolExecutor(max_workers=5)
+        max_workers = configs.get()['system'].get('push_task_workers', 5)
+        self.generate_executor = ThreadPoolExecutor(max_workers=max_workers)
         self.send_executors = {}
         self.rmq_topic = mq_topic
         self.consumer = mq_consumer
@@ -168,7 +169,9 @@ class PushTaskWorkerPool:
             push_agent = MessagePushAgent()
             message_to_user = push_agent.generate_message(
                 context=main_agent.get_prompt_context(None),
-                dialogue_history=main_agent.dialogue_history
+                dialogue_history=self.agent_service.history_dialogue_db.get_dialogue_history_backward(
+                    staff_id, user_id, main_agent.last_interaction_time, limit=100
+                )
             )
             rmq_message = generate_task_rmq_message(self.rmq_topic, staff_id, user_id, TaskType.SEND, message_to_user)
             logger.debug(f"send message: {rmq_message.body.decode('utf-8')}")