浏览代码

Update message and history_dialogue_service: deal with voice call type

StrayWarrior 1 周之前
父节点
当前提交
46b0004393
共有 2 个文件被更改,包括 7 次插入31 次删除
  1. 6 2
      history_dialogue_service.py
  2. 1 29
      message.py

+ 6 - 2
history_dialogue_service.py

@@ -38,12 +38,16 @@ class HistoryDialogueService:
                 logger.warning("Unknown sender in dialogue history: {}".format(sender))
                 logger.warning("Unknown sender in dialogue history: {}".format(sender))
                 continue
                 continue
             msg_type = record.get('type', MessageType.TEXT.value)
             msg_type = record.get('type', MessageType.TEXT.value)
-            ret.append({
+            message = {
                 'role': role,
                 'role': role,
                 'content': record.get('content', ''),
                 'content': record.get('content', ''),
                 'timestamp': record.get('sendTime', 0),
                 'timestamp': record.get('sendTime', 0),
                 'type': MessageType(msg_type)
                 'type': MessageType(msg_type)
-            })
+            }
+            if message['type'] in (MessageType.VOICE_VIDEO_CALL, ):
+                logger.warning(f"staff[{staff_id}], user[{user_id}]: skip unsupported message type {message['type']}")
+                continue
+            ret.append(message)
         ret = sorted(ret, key=lambda x: x['timestamp'])
         ret = sorted(ret, key=lambda x: x['timestamp'])
         return ret
         return ret
 
 

+ 1 - 29
message.py

@@ -9,35 +9,6 @@ from typing import Optional
 import rocketmq
 import rocketmq
 from pydantic import BaseModel
 from pydantic import BaseModel
 
 
-# class MessageType(Enum):
-#     DEFAULT = (-1, "未分类的消息")
-#     TEXT = (1, "文本")
-#     VOICE = (2, "语音")
-#     GIF = (3, "GIF")
-#     IMAGE_GW = (4, "个微图片")
-#     IMAGE_QW = (5, "企微图片")
-#     MINI_PROGRAM = (6, "小程序")
-#     LINK = (7, "链接")
-#     SHI_PIN_HAO = (8, "视频号")
-#     NAME_CARD = (9, "名片")
-#     POSITION = (10, "位置")
-#     RED_PACKET = (11, "红包")
-#     FILE_GW = (12, "个微文件")
-#     FILE_QW = (13, "企微文件")
-#     VIDEO_GW = (14, "个微视频")
-#     VIDEO_QW = (15, "企微视频")
-#     AGGREGATION_MSG = (16, "聚合消息")
-#
-#     ACTIVE_TRIGGER = (101, "主动触发器")
-#     AGGREGATION_TRIGGER = (102, "消息聚合触发器")
-#
-#     def __init__(self, code, description):
-#         self.code = code
-#         self.description = description
-#
-#     def __repr__(self):
-#         return f"{self.__class__.__name__}.{self.name}"
-
 class MessageType(int, Enum):
 class MessageType(int, Enum):
     DEFAULT = -1
     DEFAULT = -1
     TEXT = 1
     TEXT = 1
@@ -56,6 +27,7 @@ class MessageType(int, Enum):
     VIDEO_GW = 14
     VIDEO_GW = 14
     VIDEO_QW = 15
     VIDEO_QW = 15
     AGGREGATION_MSG = 16
     AGGREGATION_MSG = 16
+    VOICE_VIDEO_CALL = 17
 
 
     ACTIVE_TRIGGER = 101
     ACTIVE_TRIGGER = 101
     AGGREGATION_TRIGGER = 102
     AGGREGATION_TRIGGER = 102