Browse Source

Update staff profile to version v2 (temporary changes)

StrayWarrior 2 ngày trước cách đây
mục cha
commit
730a486013
2 tập tin đã thay đổi với 7 bổ sung4 xóa
  1. 6 3
      pqai_agent/dialogue_manager.py
  2. 1 1
      pqai_agent/user_manager.py

+ 6 - 3
pqai_agent/dialogue_manager.py

@@ -153,7 +153,9 @@ class DialogueManager:
             return TimeContext.NIGHT
 
     def is_valid(self):
-        if not self.staff_profile.get('name', None) and not self.staff_profile.get('agent_name', None):
+        if not self.staff_profile.get('name', None) \
+                and not self.staff_profile.get('agent_name', None) \
+                and not self.staff_profile.get('基础信息', {}).get('昵称', None):
             return False
         return True
 
@@ -358,7 +360,8 @@ class DialogueManager:
 
     def _send_alert(self, alert_type: str, reason: Optional[str] = None) -> None:
         time_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
-        staff_info = f"{self.staff_profile.get('name', '未知')}[{self.staff_id}]"
+        name = self.staff_profile.get('name', None) or self.staff_profile.get('基础信息', {}).get('昵称', None)
+        staff_info = f"{name}[{self.staff_id}]"
         user_info = f"{self.user_profile.get('nickname', '未知')}[{self.user_id}]"
         alert_message = f"""
         {alert_type}告警
@@ -567,7 +570,7 @@ class DialogueManager:
             "if_first_interaction": True if self.previous_state == DialogueState.INITIALIZED else False,
             "if_active_greeting": False if user_message else True,
             "relation_stage": self.relation_stage,
-            "formatted_staff_profile": prompt_utils.format_agent_profile(self.staff_profile),
+            "formatted_staff_profile": prompt_utils.format_agent_profile_v2(self.staff_profile),
             "formatted_user_profile": prompt_utils.format_user_profile(self.user_profile),
             **self.user_profile,
             **legacy_staff_profile

+ 1 - 1
pqai_agent/user_manager.py

@@ -228,7 +228,7 @@ class MySQLUserManager(UserManager):
         return profile
 
     def get_staff_profile_v3(self, staff_id) -> Dict:
-        sql = f"SELECT agent_profile " \
+        sql = f"SELECT agent_profile_v2 " \
               f"FROM {self.staff_table} WHERE third_party_user_id = '{staff_id}'"
         data = self.db.select(sql)
         if not data: