Browse Source

Update agent_service: add apollo config

StrayWarrior 1 week ago
parent
commit
1287bb819d
1 changed files with 5 additions and 6 deletions
  1. 5 6
      agent_service.py

+ 5 - 6
agent_service.py

@@ -16,6 +16,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
 import chat_service
 import configs
 import logging_service
+from configs import apollo_config
 from logging_service import logger
 from chat_service import CozeChat, ChatServiceType
 from dialogue_manager import DialogueManager, DialogueState, DialogueStateCache
@@ -166,14 +167,12 @@ class AgentService:
         logger.warning(f"staff[{staff_id}] user[{user_id}]: response[{message_type}] {response}")
         current_ts = int(time.time() * 1000)
         user_tags = self.user_relation_manager.get_user_tags(user_id)
-        white_list_tags = {'AgentTest1', '04W4-YR-1', '04W4-YR-2', '04W4-KK-1', '04W4-SQ-1', 'agent 托管'}
+        white_list_tags = set(apollo_config.get_json_value("agent_response_whitelist_tags"))
         hit_white_list_tags = len(set(user_tags).intersection(white_list_tags)) > 0
         # FIXME(zhoutian)
         # 测试期间临时逻辑,只发送特定的账号或特定用户
-        user_black_lists = ['7881300148979455',]
-        staff_white_lists = ['1688854492669990',]
-        if not (staff_id in staff_white_lists or hit_white_list_tags) \
-                or user_id in user_black_lists:
+        staff_white_lists = set(apollo_config.get_json_value("agent_response_whitelist_staffs"))
+        if not (staff_id in staff_white_lists or hit_white_list_tags):
             logger.warning(f"staff[{staff_id}] user[{user_id}]: skip reply")
             return None
         self.send_queue.produce(
@@ -200,7 +199,7 @@ class AgentService:
             agent = self._get_agent_instance(staff_id, user_id)
             should_initiate = agent.should_initiate_conversation()
             user_tags = self.user_relation_manager.get_user_tags(user_id)
-            white_list_tags = {}
+            white_list_tags = apollo_config.get_json_value('agent_initiate_whitelist_tags')
             if not set(user_tags).intersection(white_list_tags):
                 should_initiate = False