|
@@ -122,12 +122,16 @@ class DialogueManager:
|
|
|
|
|
|
def persist_state(self):
|
|
def persist_state(self):
|
|
"""持久化对话状态"""
|
|
"""持久化对话状态"""
|
|
|
|
+ config = configs.get()
|
|
|
|
+ if not config.get('debug_flags', {}).get('disable_state_persistence', False):
|
|
|
|
+ return
|
|
self.state_cache.set_state(self.staff_id, self.user_id, self.current_state, self.previous_state)
|
|
self.state_cache.set_state(self.staff_id, self.user_id, self.current_state, self.previous_state)
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
- def get_current_time_context() -> TimeContext:
|
|
|
|
|
|
+ def get_time_context(current_hour=None) -> TimeContext:
|
|
"""获取当前时间上下文"""
|
|
"""获取当前时间上下文"""
|
|
- current_hour = datetime.now().hour
|
|
|
|
|
|
+ if not current_hour:
|
|
|
|
+ current_hour = datetime.now().hour
|
|
if 5 <= current_hour < 8:
|
|
if 5 <= current_hour < 8:
|
|
return TimeContext.EARLY_MORNING
|
|
return TimeContext.EARLY_MORNING
|
|
elif 8 <= current_hour < 12:
|
|
elif 8 <= current_hour < 12:
|
|
@@ -362,7 +366,7 @@ class DialogueManager:
|
|
|
|
|
|
hours_passed = self._get_hours_since_last_interaction()
|
|
hours_passed = self._get_hours_since_last_interaction()
|
|
# 获取当前时间上下文
|
|
# 获取当前时间上下文
|
|
- time_context = self.get_current_time_context()
|
|
|
|
|
|
+ time_context = self.get_time_context()
|
|
|
|
|
|
# 根据用户交互频率偏好设置不同的阈值
|
|
# 根据用户交互频率偏好设置不同的阈值
|
|
interaction_frequency = self.user_profile.get("interaction_frequency", "medium")
|
|
interaction_frequency = self.user_profile.get("interaction_frequency", "medium")
|
|
@@ -394,7 +398,7 @@ class DialogueManager:
|
|
|
|
|
|
def get_prompt_context(self, user_message) -> Dict:
|
|
def get_prompt_context(self, user_message) -> Dict:
|
|
# 获取当前时间上下文
|
|
# 获取当前时间上下文
|
|
- time_context = self.get_current_time_context()
|
|
|
|
|
|
+ time_context = self.get_time_context()
|
|
# 刷新用户画像
|
|
# 刷新用户画像
|
|
self.user_profile = self.user_manager.get_user_profile(self.user_id)
|
|
self.user_profile = self.user_manager.get_user_profile(self.user_id)
|
|
# 刷新员工画像(不一定需要)
|
|
# 刷新员工画像(不一定需要)
|