Bläddra i källkod

Update response_type_detector: prefer to use voice if user uses voice

StrayWarrior 6 dagar sedan
förälder
incheckning
db1e42d564
2 ändrade filer med 9 tillägg och 5 borttagningar
  1. 7 4
      prompt_templates.py
  2. 2 1
      response_type_detector.py

+ 7 - 4
prompt_templates.py

@@ -227,14 +227,17 @@ RESPONSE_TYPE_DETECT_PROMPT = """
 * 根据历史对话判断,当前消息是否需要以语音的形式发送
 
 # 规则和注意事项
-* 只有用户明确希望使用语音形式回复时才应该选择语音
+* 默认使用文本
+* 如果用户明确提到使用语音形式,尽量选择语音
+* 用户自身偏向于使用语音形式沟通时,可选择语音
+* 注意分析即将发送的消息内容,如果有不适合使用语音朗读的内容,不要选择使用语音
 * 注意对话中包含的时间!注意时间流逝和情境切换!判断合适的回复方式!
 
 # 输入格式
 ## 历史对话格式
-[用户] [时间] 内容...
-[客服] [时间] 内容...
-[用户] [时间] 内容...
+[用户][时间][形式] 内容...
+[客服][时间][形式] 内容...
+[用户][时间][形式] 内容...
 
 ## 即将发送的消息格式
 [时间] 内容...

+ 2 - 1
response_type_detector.py

@@ -26,8 +26,9 @@ class ResponseTypeDetector:
                 continue
             if msg['role'] not in role_map:
                 continue
+            msg_type = msg.get('type', MessageType.TEXT)
             fmt_time = datetime.fromtimestamp(msg['timestamp'] / 1000).strftime('%Y-%m-%d %H:%M:%S')
-            messages.append('[{}] [{}] {}'.format(role_map[msg['role']], fmt_time, msg['content']))
+            messages.append('[{}][{}][{}] {}'.format(role_map[msg['role']], fmt_time, msg_type.description, msg['content']))
         return '\n'.join(messages)
 
     def __init__(self):