105 lines
3.3 KiB
Go
105 lines
3.3 KiB
Go
package redis
|
||
|
||
// SendStreamMessage 发送到 Redis Stream 的消息结构
|
||
type SendStreamMessage struct {
|
||
UserId string `json:"user_id"` // 用户ID
|
||
Content string `json:"content"` // 消息内容
|
||
Timestamp int64 `json:"timestamp"` // 时间戳(秒)
|
||
MessageId string `json:"message_id"` // 消息唯一ID
|
||
}
|
||
|
||
// ToMap 转换为 map[string]interface{} 用于 Stream 存储
|
||
func (m *SendStreamMessage) ToMap() map[string]interface{} {
|
||
return map[string]interface{}{
|
||
"user_id": m.UserId,
|
||
"content": m.Content,
|
||
"timestamp": m.Timestamp,
|
||
"message_id": m.MessageId,
|
||
}
|
||
}
|
||
|
||
// BatchStreamMessage 批量消息结构
|
||
type BatchStreamMessage struct {
|
||
UserId string `json:"user_id"` // 用户ID
|
||
Content string `json:"content"` // 消息内容
|
||
Timestamp int64 `json:"timestamp"` // 时间戳(秒)
|
||
BatchId string `json:"batch_id"` // 批次ID
|
||
Index int `json:"index"` // 批次内序号
|
||
}
|
||
|
||
// ToMap 转换为 map[string]interface{} 用于 Stream 存储
|
||
func (m *BatchStreamMessage) ToMap() map[string]interface{} {
|
||
return map[string]interface{}{
|
||
"user_id": m.UserId,
|
||
"content": m.Content,
|
||
"timestamp": m.Timestamp,
|
||
"batch_id": m.BatchId,
|
||
"index": m.Index,
|
||
}
|
||
}
|
||
|
||
// ResponseStreamMessage RAGFlow 响应消息结构(写入结果 Stream)
|
||
type ResponseStreamMessage struct {
|
||
UserId string `json:"user_id"` // 用户ID
|
||
Platform string `json:"platform"` // 平台标识
|
||
Question string `json:"question"` // 用户问题
|
||
Content string `json:"content"` // RAGFlow 回复内容
|
||
SessionId string `json:"session_id"` // RAGFlow Session ID
|
||
Timestamp int64 `json:"timestamp"` // 时间戳(秒)
|
||
MessageId string `json:"message_id"` // 原始消息ID
|
||
}
|
||
|
||
// ToMap 转换为 map[string]interface{} 用于 Stream 存储
|
||
func (m *ResponseStreamMessage) ToMap() map[string]interface{} {
|
||
return map[string]interface{}{
|
||
"user_id": m.UserId,
|
||
"platform": m.Platform,
|
||
"question": m.Question,
|
||
"content": m.Content,
|
||
"session_id": m.SessionId,
|
||
"timestamp": m.Timestamp,
|
||
"message_id": m.MessageId,
|
||
}
|
||
}
|
||
|
||
// FollowUpMessage 追问消息结构(RabbitMQ 延时队列)
|
||
type FollowUpMessage struct {
|
||
UserId string `json:"user_id"` // 用户ID
|
||
Platform string `json:"platform"` // 平台标识
|
||
Content string `json:"content"` // 追问内容
|
||
FollowUpType int `json:"follow_up_type"` // 追问类型:1=30s, 2=60s, 3=180s
|
||
Timestamp int64 `json:"timestamp"` // 发送时间戳
|
||
}
|
||
|
||
// 追问话术常量
|
||
const (
|
||
FollowUpType1 = 1 // 30秒追问
|
||
FollowUpType2 = 2 // 60秒追问
|
||
FollowUpType3 = 3 // 180秒追问
|
||
)
|
||
|
||
// 追问话术内容
|
||
var FollowUpContents = map[int]string{
|
||
FollowUpType1: "还有其他问题吗?",
|
||
FollowUpType2: "如果需要帮助,随时告诉我~",
|
||
FollowUpType3: "我一直在线,有问题随时找我~",
|
||
}
|
||
|
||
// 追问延时时间(秒)
|
||
var FollowUpDelays = map[int]int{
|
||
FollowUpType1: 30,
|
||
FollowUpType2: 60,
|
||
FollowUpType3: 180,
|
||
}
|
||
|
||
// ArchiveMessage 会话归档消息结构(RabbitMQ 延时队列)
|
||
type ArchiveMessage struct {
|
||
UserId string `json:"user_id"` // 用户ID
|
||
Platform string `json:"platform"` // 平台标识
|
||
SessionId string `json:"session_id"` // RAGFlow Session ID
|
||
Timestamp int64 `json:"timestamp"` // 发送时间戳
|
||
}
|
||
|
||
// 归档延时时间(秒)
|
||
const ArchiveDelaySeconds = 3600 // 60分钟
|