Selaa lähdekoodia

Update: enable testing account active conversation

StrayWarrior 1 viikko sitten
vanhempi
commit
880a736eed
3 muutettua tiedostoa jossa 8 lisäystä ja 5 poistoa
  1. 6 3
      agent_service.py
  2. 1 1
      dialogue_manager.py
  3. 1 1
      user_manager.py

+ 6 - 3
agent_service.py

@@ -168,8 +168,9 @@ 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))
+                resp = self._get_chat_response(user_id, agent, None)
+                if resp:
+                    time.sleep(random.randint(10,20))
             else:
                 logger.debug("user: {}, do not initiate conversation".format(user_id))
 
@@ -190,13 +191,15 @@ class AgentService:
             if not (agent.staff_id in set(['1688854492669990'])
                     or 'AgentTest1' in user_tags):
                 logger.warning(f"staff[{agent.staff_id}] user[{user_id}]: skip reply")
-                return
+                return None
             self.send_queue.produce(
                 Message.build(MessageType.TEXT, MessageChannel.CORP_WECHAT,
                               agent.staff_id, user_id, response, current_ts)
             )
+            return response
         else:
             logger.warning(f"staff[{agent.staff_id}] user[{user_id}]: no response generated")
+            return None
 
     def _call_chat_api(self, chat_config: Dict) -> str:
         if configs.get().get('debug_flags', {}).get('disable_llm_api_call', False):

+ 1 - 1
dialogue_manager.py

@@ -65,7 +65,7 @@ class DialogueStateCache:
         data = self.db.select(query, pymysql.cursors.DictCursor, (staff_id, user_id))
         if not data:
             logger.warning(f"staff[{staff_id}], user[{user_id}]: agent state not found")
-            state = DialogueState.CHITCHAT
+            state = DialogueState.INITIALIZED
             previous_state = DialogueState.INITIALIZED
             self.set_state(staff_id, user_id, state, previous_state)
         else:

+ 1 - 1
user_manager.py

@@ -193,7 +193,7 @@ class MySQLUserRelationManager(UserRelationManager):
         # FIXME(zhoutian)
         # 测试期间逻辑,只取一个账号
         sql = (f"SELECT third_party_user_id, wxid FROM {self.agent_staff_table} WHERE status = 1"
-               f" AND third_party_user_id = '1688854492669990'")
+               f" AND third_party_user_id in ('1688854492669990', '1688855931724582')")
         agent_staff_data = self.agent_db.select(sql, pymysql.cursors.DictCursor)
         if not agent_staff_data:
             return []