重构了一下 rag的方法, 使用 goframe的框架, 还有redis连接部分

This commit is contained in:
Cold
2025-12-06 18:04:29 +08:00
committed by 张斌
parent f7cb007491
commit 4b2b5e6177
16 changed files with 398 additions and 260 deletions

View File

@@ -37,3 +37,68 @@ func (m *BatchStreamMessage) ToMap() map[string]interface{} {
"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分钟