feat: rag初始版
This commit is contained in:
26
consts/document/status.go
Normal file
26
consts/document/status.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package document
|
||||
|
||||
import "github.com/gogf/gf/v2/util/gconv"
|
||||
|
||||
var (
|
||||
StatusDisable = newStatus(gconv.PtrInt8(0), "disable")
|
||||
StatusEnable = newStatus(gconv.PtrInt8(1), "enable")
|
||||
)
|
||||
|
||||
type Status *int8
|
||||
|
||||
type status struct {
|
||||
code Status
|
||||
desc string
|
||||
}
|
||||
|
||||
func (s status) Code() Status {
|
||||
return s.code
|
||||
}
|
||||
func (s status) Desc() string {
|
||||
return s.desc
|
||||
}
|
||||
|
||||
func newStatus(code Status, desc string) status {
|
||||
return status{code: code, desc: desc}
|
||||
}
|
||||
28
consts/document/vector_status.go
Normal file
28
consts/document/vector_status.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package document
|
||||
|
||||
import "github.com/gogf/gf/v2/util/gconv"
|
||||
|
||||
var (
|
||||
VectorStatusPending = newVectorStatus(gconv.PtrInt8(1), "pending")
|
||||
VectorStatusProcessing = newVectorStatus(gconv.PtrInt8(2), "processing")
|
||||
VectorStatusCompleted = newVectorStatus(gconv.PtrInt8(3), "completed")
|
||||
VectorStatusFailed = newVectorStatus(gconv.PtrInt8(4), "failed")
|
||||
)
|
||||
|
||||
type VectorStatus *int8
|
||||
|
||||
type vectorStatus struct {
|
||||
code VectorStatus
|
||||
desc string
|
||||
}
|
||||
|
||||
func (s vectorStatus) Code() VectorStatus {
|
||||
return s.code
|
||||
}
|
||||
func (s vectorStatus) Desc() string {
|
||||
return s.desc
|
||||
}
|
||||
|
||||
func newVectorStatus(code VectorStatus, desc string) vectorStatus {
|
||||
return vectorStatus{code: code, desc: desc}
|
||||
}
|
||||
20
consts/public/redis_key.go
Normal file
20
consts/public/redis_key.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package public
|
||||
|
||||
const KnowledgeLockEsKey = "rag:knowledge:lock:knowledgeIdEs-%v"
|
||||
const KnowledgeLockSqlKey = "rag:knowledge:lock:knowledgeIdSql-%v"
|
||||
const KnowledgeContentHashEsKey = "rag:knowledge:knowledgeId:contentHashEs-%v"
|
||||
const KnowledgeContentHashSqlKey = "rag:knowledge:knowledgeId:contentHashSql-%v"
|
||||
|
||||
const (
|
||||
KnowledgeDocumentVectorStatusTopic = "knowledge:document:vector:status:stream"
|
||||
KnowledgeDocumentVectorStatusConsumer = "knowledge-document-vector-status-consumer"
|
||||
KnowledgeDocumentVectorStatusBatchSize = 1
|
||||
KnowledgeDocumentVectorStatusAutoAck = false
|
||||
)
|
||||
|
||||
const (
|
||||
KnowledgeDocumentChunkTopic = "knowledge:document:chunk:stream" // 请求 Stream 键名(与发消息的key一致)
|
||||
KnowledgeDocumentChunkConsumer = "knowledge-document-chunk-consumer" // 消费者名称(唯一标识)
|
||||
KnowledgeDocumentChunkBatchSize = 1 // 批处理大小(每次读取1条)
|
||||
KnowledgeDocumentChunkAutoAck = false // ACK是否自动确认(true自动确认,false不确认)
|
||||
)
|
||||
15
consts/public/table_name.go
Normal file
15
consts/public/table_name.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package public
|
||||
|
||||
// sql 数据库表名
|
||||
const (
|
||||
TableNameDocument = "document"
|
||||
TableNameDataset = "dataset"
|
||||
TableNameKeyword = "keyword"
|
||||
TableNameDatasetIndex = "dataset_index"
|
||||
TableNameDocumentChunk = "document_chunk"
|
||||
)
|
||||
|
||||
// es 索引名称
|
||||
const (
|
||||
IndexNameDocumentChunk = "document_chunk" // 文档分块索引
|
||||
)
|
||||
Reference in New Issue
Block a user