|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
import sys
|
|
|
import time
|
|
|
+import random
|
|
|
from typing import Dict, List, Tuple, Any, Optional
|
|
|
import logging
|
|
|
from datetime import datetime, timedelta
|
|
@@ -168,6 +169,7 @@ class AgentService:
|
|
|
if should_initiate:
|
|
|
logger.warning("user: {}, initiate conversation".format(user_id))
|
|
|
self._get_chat_response(user_id, agent, None)
|
|
|
+ time.sleep(random.randint(10,20))
|
|
|
else:
|
|
|
logger.debug("user: {}, do not initiate conversation".format(user_id))
|
|
|
|
|
@@ -182,10 +184,12 @@ class AgentService:
|
|
|
if response := agent.generate_response(chat_response):
|
|
|
logger.warning(f"staff[{agent.staff_id}] user[{user_id}]: response: {response}")
|
|
|
current_ts = int(time.time() * 1000)
|
|
|
+ user_tags = self.user_relation_manager.get_user_tags(user_id)
|
|
|
# FIXME(zhoutian)
|
|
|
- # 测试期间临时逻辑,只发送特定的用户
|
|
|
- if agent.staff_id not in set(['1688854492669990']):
|
|
|
- logger.warning(f"skip message from sender [{agent.staff_id}]")
|
|
|
+ # 测试期间临时逻辑,只发送特定的账号或特定用户
|
|
|
+ if not (agent.staff_id in set(['1688854492669990'])
|
|
|
+ or 'Agent测试' in user_tags):
|
|
|
+ logger.warning(f"staff[{agent.staff_id}] user[{user_id}]: skip reply")
|
|
|
return
|
|
|
self.send_queue.produce(
|
|
|
Message.build(MessageType.TEXT, MessageChannel.CORP_WECHAT,
|
|
@@ -288,7 +292,7 @@ if __name__ == "__main__":
|
|
|
if not text:
|
|
|
continue
|
|
|
message_id += 1
|
|
|
- sender = '7881302581935903'
|
|
|
+ sender = '7881299670930896'
|
|
|
receiver = '1688854492669990'
|
|
|
if text == MessageType.AGGREGATION_TRIGGER.name:
|
|
|
message = Message.build(MessageType.AGGREGATION_TRIGGER, MessageChannel.CORP_WECHAT,
|