|
@@ -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):
|