Files
common/redis/types.go

105 lines
3.6 KiB
Go
Raw Normal View History

package redis
2025-12-09 09:20:44 +08:00
import "gitee.com/red-future---jilin-g/common/config"
// HistoryMessage 历史消息结构(用于上下文注入)
type HistoryMessage struct {
Question string `json:"question"` // 用户问题
Answer string `json:"answer"` // AI 回复
}
2025-12-09 09:20:44 +08:00
// 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
Platform string `json:"platform,omitempty"` // 平台标识
AccountId string `json:"account_id,omitempty"` // 账号ID
TenantId string `json:"tenant_id,omitempty"` // 租户ID数据隔离
History []HistoryMessage `json:"history,omitempty"` // 历史对话(归档后恢复时携带)
}
// 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"` // 批次内序号
}
2025-12-09 09:20:44 +08:00
// ResponseStreamMessage RAGFlow 响应消息结构MQ 消息)
type ResponseStreamMessage struct {
UserId string `json:"user_id"` // 用户ID
Platform string `json:"platform"` // 平台标识
2025-12-09 09:20:44 +08:00
TenantId string `json:"tenant_id"` // 租户ID
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
}
// 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"` // 发送时间戳
}
2025-12-09 09:20:44 +08:00
// 追问类型常量
const (
2025-12-09 09:20:44 +08:00
FollowUpType1 = 1 // 第一次追问
FollowUpType2 = 2 // 第二次追问
FollowUpType3 = 3 // 第三次追问
)
2025-12-09 09:20:44 +08:00
// GetFollowUpContent 获取追问话术(从 config 包读取)
func GetFollowUpContent(followUpType int) string {
switch followUpType {
case FollowUpType1:
return config.FollowUpContent1
case FollowUpType2:
return config.FollowUpContent2
case FollowUpType3:
return config.FollowUpContent3
default:
return ""
}
}
2025-12-09 09:20:44 +08:00
// GetFollowUpDelay 获取追问延时(从 config 包读取)
func GetFollowUpDelay(followUpType int) int {
switch followUpType {
case FollowUpType1:
return config.FollowUpDelay1
case FollowUpType2:
return config.FollowUpDelay2
case FollowUpType3:
return config.FollowUpDelay3
default:
return 0
}
}
// 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"` // 发送时间戳
}
2025-12-09 09:20:44 +08:00
// GetArchiveDelay 获取归档延时(从 config 包读取)
func GetArchiveDelay() int {
return config.ArchiveDelay
}
// GetHistoryContextLimit 获取历史上下文轮数(从 config 包读取)
func GetHistoryContextLimit() int64 {
return config.HistoryContextLimit
}