feat: rag初始版
This commit is contained in:
69
model/dto/dataset.go
Normal file
69
model/dto/dataset.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// CreateDatasetReq 创建数据集请求
|
||||
type CreateDatasetReq struct {
|
||||
g.Meta `path:"/createDataset" method:"post" tags:"知识库(数据集)管理" summary:"创建知识库(数据集)" dc:"创建知识库(数据集)"`
|
||||
|
||||
Name string `json:"name" v:"required#名称不能为空"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// CreateDatasetRes 创建数据集响应
|
||||
type CreateDatasetRes struct {
|
||||
Id int64 `json:"id,string"`
|
||||
}
|
||||
|
||||
// UpdateDatasetReq 更新数据集请求
|
||||
type UpdateDatasetReq struct {
|
||||
g.Meta `path:"/updateDataset" method:"put" tags:"知识库(数据集)管理" summary:"更新知识库(数据集)" dc:"更新知识库(数据集)"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
DocumentCount int64 `json:"documentCount"`
|
||||
DocumentSize int64 `json:"documentSize"`
|
||||
}
|
||||
|
||||
// DeleteDatasetReq 删除数据集请求
|
||||
type DeleteDatasetReq struct {
|
||||
g.Meta `path:"/deleteDataset" method:"delete" tags:"知识库(数据集)管理" summary:"删除知识库(数据集)" dc:"删除知识库(数据集)"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
// GetDatasetReq 获取数据集请求
|
||||
type GetDatasetReq struct {
|
||||
g.Meta `path:"/getDataset" method:"get" tags:"知识库(数据集)管理" summary:"获取知识库(数据集)详情" dc:"获取知识库(数据集)详情"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
// ListDatasetReq 数据集列表请求
|
||||
type ListDatasetReq struct {
|
||||
g.Meta `path:"/listDataset" method:"get" tags:"知识库(数据集)管理" summary:"获取知识库(数据集)列表" dc:"分页查询知识库(数据集)列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
}
|
||||
|
||||
// ListDatasetRes 数据集列表响应
|
||||
type ListDatasetRes struct {
|
||||
List []*DatasetVO `json:"list"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type DatasetVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Name string `json:"name" dc:"数据集名称"`
|
||||
Description string `json:"description" dc:"数据集描述"`
|
||||
DocumentCount int64 `json:"documentCount" dc:"文件数量"`
|
||||
DocumentSize int64 `json:"documentSize" dc:"文件大小(字节)"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
1
model/dto/dataset_index.go
Normal file
1
model/dto/dataset_index.go
Normal file
@@ -0,0 +1 @@
|
||||
package dto
|
||||
108
model/dto/document.go
Normal file
108
model/dto/document.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"rag/consts/document"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// CreateDocumentReq 创建文件请求
|
||||
type CreateDocumentReq struct {
|
||||
g.Meta `path:"/createDocument" method:"post" tags:"文件管理" summary:"创建文件" dc:"创建文件"`
|
||||
|
||||
DatasetId int64 `json:"datasetId" v:"required#数据集ID不能为空"`
|
||||
Title string `json:"title" v:"required#标题不能为空"`
|
||||
Format string `json:"format" v:"required#格式不能为空"`
|
||||
FileSize int64 `json:"fileSize" v:"required#大小不能为空"`
|
||||
FilePath string `json:"filePath" v:"required#路径不能为空"`
|
||||
}
|
||||
|
||||
// CreateDocumentRes 创建文件响应
|
||||
type CreateDocumentRes struct {
|
||||
Id int64 `json:"id,string"`
|
||||
}
|
||||
|
||||
// UpdateDocumentReq 更新文件请求
|
||||
type UpdateDocumentReq struct {
|
||||
g.Meta `path:"/updateDocument" method:"put" tags:"文件管理" summary:"更新文件" dc:"更新文件"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Status document.Status `json:"status"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus"`
|
||||
ChunkCount int64 `json:"chunkCount"`
|
||||
}
|
||||
|
||||
// DeleteDocumentReq 删除文件请求
|
||||
type DeleteDocumentReq struct {
|
||||
g.Meta `path:"/deleteDocument" method:"delete" tags:"文件管理" summary:"删除文件" dc:"删除文件"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
// GetDocumentReq 获取文件请求
|
||||
type GetDocumentReq struct {
|
||||
g.Meta `path:"/getDocument" method:"get" tags:"文件管理" summary:"获取文件详情" dc:"获取文件详情"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
// ListDocumentReq 文件列表请求
|
||||
type ListDocumentReq struct {
|
||||
g.Meta `path:"/listDocument" method:"get" tags:"文件管理" summary:"获取文件列表" dc:"分页查询文件列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
Status document.Status `json:"status"`
|
||||
}
|
||||
|
||||
// ListDocumentRes 文件列表响应
|
||||
type ListDocumentRes struct {
|
||||
List []*DocumentVO `json:"list"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type DocumentVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
DatasetId int64 `json:"datasetId,string"`
|
||||
Title string `json:"title" dc:"文件标题"`
|
||||
Status document.Status `json:"status" dc:"状态1启用/0停用"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus" dc:"向量化状态 状态: 1 待定, 2 处理, 3 完成, 4 失败"`
|
||||
ChunkCount int64 `json:"chunkCount" dc:"分块数"`
|
||||
FileSize int64 `json:"fileSize" dc:"文件大小"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
// ProcessDocumentReq 处理文件请求(向量化)
|
||||
type ProcessDocumentReq struct {
|
||||
g.Meta `path:"/getProcess" method:"get" tags:"文件管理" summary:"文件向量化处理" dc:"文件向量化处理"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
DatasetId int64 `json:"datasetId" v:"required#数据集ID不能为空"`
|
||||
}
|
||||
|
||||
// ProcessDocumentRes 处理文件响应
|
||||
type ProcessDocumentRes struct {
|
||||
ChunkCount int64 `json:"chunkCount"`
|
||||
CostTime int64 `json:"costTime"`
|
||||
}
|
||||
|
||||
type ListDocumentChunkRPC struct {
|
||||
List []*DocumentChunkRPC `json:"list"`
|
||||
}
|
||||
|
||||
type DocumentChunkRPC struct {
|
||||
Id int64 `json:"id" dc:"id"`
|
||||
DatasetId int64 `json:"datasetId" dc:"所属数据集ID"`
|
||||
ContentHash string `json:"contentHash" dc:"内容hash"`
|
||||
}
|
||||
|
||||
type KnowledgeDocumentMsg struct {
|
||||
TenantId uint64 `json:"tenantId"`
|
||||
Creator string `json:"creator"`
|
||||
Id int64 `json:"id"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus"`
|
||||
}
|
||||
64
model/dto/document_chunk.go
Normal file
64
model/dto/document_chunk.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"rag/consts/document"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/pgvector/pgvector-go"
|
||||
)
|
||||
|
||||
// UpdateDocumentChunkReq 更新文件块向量请求
|
||||
type UpdateDocumentChunkReq struct {
|
||||
g.Meta `path:"/updateDocumentChunk" method:"put" tags:"文件块向量管理" summary:"更新文件块" dc:"更新文件块"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Status document.Status `json:"status"`
|
||||
}
|
||||
|
||||
// ListDocumentChunkReq 文件块向量列表请求
|
||||
type ListDocumentChunkReq struct {
|
||||
g.Meta `path:"/listDocumentChunk" method:"get" tags:"文件块向量管理" summary:"获取文件块向量列表" dc:"分页查询文件块向量列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
DocumentId int64 `json:"documentId"`
|
||||
Status document.Status `json:"status"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus"`
|
||||
}
|
||||
|
||||
// ListDocumentChunkRes 文件块向量列表响应
|
||||
type ListDocumentChunkRes struct {
|
||||
List []*DocumentChunkItem `json:"list"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type DocumentChunkItem struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Status document.Status `json:"status" dc:"状态"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus" dc:"向量状态"`
|
||||
DatasetId int64 `json:"datasetId,string" dc:"所属数据集ID"`
|
||||
DocumentId int64 `json:"documentId,string" dc:"所属文档ID"`
|
||||
Content string `json:"content" dc:"内容"`
|
||||
ContentHash string `json:"contentHash" dc:"内容hash"`
|
||||
ChunkIndex int64 `json:"chunkIndex" dc:"块索引"`
|
||||
Vector []float64 `json:"vector" dc:"向量"`
|
||||
Metadata map[string]interface{} `json:"metadata" dc:"元信息"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type VectorDocumentChunkMsg struct {
|
||||
TenantId uint64 `json:"tenantId"`
|
||||
Creator string `json:"creator"`
|
||||
DatasetId int64 `json:"datasetId"` // 数据集ID
|
||||
DocumentId int64 `json:"documentId"` // 所属文档ID
|
||||
Content string `json:"content"` // 原始内容
|
||||
ContentHash string `json:"contentHash"` // 原始内容hash
|
||||
ChunkIndex int64 `json:"chunkIndex"` // 第几块
|
||||
Status document.Status `json:"status"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus"`
|
||||
Vector pgvector.Vector `json:"vector"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
70
model/dto/keyword.go
Normal file
70
model/dto/keyword.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// CreateKeywordReq 创建关键词请求
|
||||
type CreateKeywordReq struct {
|
||||
g.Meta `path:"/createKeyword" method:"post" tags:"关键词管理" summary:"创建关键词" dc:"创建关键词"`
|
||||
|
||||
DatasetId int64 `json:"datasetId" v:"required#数据集ID不能为空"`
|
||||
DocumentId int64 `json:"documentId" v:"required#文档ID不能为空"`
|
||||
Word string `json:"word" v:"required#名称不能为空"`
|
||||
Weight int16 `json:"weight" v:"required#权重不能为空"`
|
||||
}
|
||||
|
||||
// CreateKeywordRes 创建关键词响应
|
||||
type CreateKeywordRes struct {
|
||||
Id int64 `json:"id,string"`
|
||||
}
|
||||
|
||||
// UpdateKeywordReq 更新关键词请求
|
||||
type UpdateKeywordReq struct {
|
||||
g.Meta `path:"/updateKeyword" method:"put" tags:"关键词管理" summary:"更新关键词" dc:"更新关键词"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Word string `json:"word"`
|
||||
Weight int16 `json:"weight"`
|
||||
}
|
||||
|
||||
// DeleteKeywordReq 删除关键词请求
|
||||
type DeleteKeywordReq struct {
|
||||
g.Meta `path:"/deleteKeyword" method:"delete" tags:"关键词管理" summary:"删除关键词" dc:"删除关键词"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
// GetKeywordReq 获取关键词请求
|
||||
type GetKeywordReq struct {
|
||||
g.Meta `path:"/getKeyword" method:"get" tags:"关键词管理" summary:"获取关键词详情" dc:"获取关键词详情"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
}
|
||||
|
||||
// ListKeywordReq 关键词列表请求
|
||||
type ListKeywordReq struct {
|
||||
g.Meta `path:"/listKeyword" method:"get" tags:"关键词管理" summary:"获取关键词列表" dc:"分页查询关键词列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
DocumentId int64 `json:"documentId"`
|
||||
Word string `json:"word"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
}
|
||||
|
||||
// ListKeywordRes 关键词列表响应
|
||||
type ListKeywordRes struct {
|
||||
List []*KeywordVO `json:"list"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type KeywordVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Word string `json:"word" dc:"关键词名称"`
|
||||
Weight int16 `json:"weight" dc:"权重"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
Reference in New Issue
Block a user