refactor: 重构文档向量相关代码结构
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// CreateDatasetReq 创建数据集请求
|
||||
type CreateDatasetReq struct {
|
||||
g.Meta `path:"/createDataset" method:"post" tags:"知识库(数据集)管理" summary:"创建知识库(数据集)" dc:"创建知识库(数据集)"`
|
||||
g.Meta `path:"/create" method:"post" tags:"知识库(数据集)管理" summary:"创建知识库(数据集)" dc:"创建知识库(数据集)"`
|
||||
|
||||
Name string `json:"name" v:"required#名称不能为空"`
|
||||
Description string `json:"description"`
|
||||
@@ -21,7 +21,7 @@ type CreateDatasetRes struct {
|
||||
|
||||
// UpdateDatasetReq 更新数据集请求
|
||||
type UpdateDatasetReq struct {
|
||||
g.Meta `path:"/updateDataset" method:"put" tags:"知识库(数据集)管理" summary:"更新知识库(数据集)" dc:"更新知识库(数据集)"`
|
||||
g.Meta `path:"/update" method:"put" tags:"知识库(数据集)管理" summary:"更新知识库(数据集)" dc:"更新知识库(数据集)"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Name string `json:"name"`
|
||||
@@ -32,21 +32,21 @@ type UpdateDatasetReq struct {
|
||||
|
||||
// DeleteDatasetReq 删除数据集请求
|
||||
type DeleteDatasetReq struct {
|
||||
g.Meta `path:"/deleteDataset" method:"delete" tags:"知识库(数据集)管理" summary:"删除知识库(数据集)" dc:"删除知识库(数据集)"`
|
||||
g.Meta `path:"/delete" 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:"获取知识库(数据集)详情"`
|
||||
g.Meta `path:"/get" 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:"分页查询知识库(数据集)列表,支持多条件筛选"`
|
||||
g.Meta `path:"/list" method:"get" tags:"知识库(数据集)管理" summary:"获取知识库(数据集)列表" dc:"分页查询知识库(数据集)列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
// CreateDocumentReq 创建文件请求
|
||||
type CreateDocumentReq struct {
|
||||
g.Meta `path:"/createDocument" method:"post" tags:"文件管理" summary:"创建文件" dc:"创建文件"`
|
||||
g.Meta `path:"/create" method:"post" tags:"文件管理" summary:"创建文件" dc:"创建文件"`
|
||||
|
||||
DatasetId int64 `json:"datasetId" v:"required#数据集ID不能为空"`
|
||||
Title string `json:"title" v:"required#标题不能为空"`
|
||||
@@ -26,7 +26,7 @@ type CreateDocumentRes struct {
|
||||
|
||||
// UpdateDocumentReq 更新文件请求
|
||||
type UpdateDocumentReq struct {
|
||||
g.Meta `path:"/updateDocument" method:"put" tags:"文件管理" summary:"更新文件" dc:"更新文件"`
|
||||
g.Meta `path:"/update" method:"put" tags:"文件管理" summary:"更新文件" dc:"更新文件"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Status document.Status `json:"status"`
|
||||
@@ -36,21 +36,21 @@ type UpdateDocumentReq struct {
|
||||
|
||||
// DeleteDocumentReq 删除文件请求
|
||||
type DeleteDocumentReq struct {
|
||||
g.Meta `path:"/deleteDocument" method:"delete" tags:"文件管理" summary:"删除文件" dc:"删除文件"`
|
||||
g.Meta `path:"/delete" 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:"获取文件详情"`
|
||||
g.Meta `path:"/get" 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:"分页查询文件列表,支持多条件筛选"`
|
||||
g.Meta `path:"/list" method:"get" tags:"文件管理" summary:"获取文件列表" dc:"分页查询文件列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
@@ -76,27 +76,16 @@ type DocumentVO struct {
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
// ProcessDocumentReq 处理文件请求(向量化)
|
||||
type ProcessDocumentReq struct {
|
||||
g.Meta `path:"/getProcess" method:"get" tags:"文件管理" summary:"文件向量化处理" dc:"文件向量化处理"`
|
||||
// DocumentVectorReq 处理文件请求(向量化)
|
||||
type DocumentVectorReq struct {
|
||||
g.Meta `path:"/vectorization" method:"post" tags:"文件管理" summary:"文件向量化处理" dc:"文件向量化处理"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
DatasetId int64 `json:"datasetId" v:"required#数据集ID不能为空"`
|
||||
}
|
||||
|
||||
type ListDocumentChunkRPC struct {
|
||||
List []*DocumentChunkRPC `json:"list"`
|
||||
}
|
||||
|
||||
type DocumentChunkRPC struct {
|
||||
type DocumentVectorRPC 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"`
|
||||
}
|
||||
|
||||
@@ -9,17 +9,37 @@ import (
|
||||
"github.com/pgvector/pgvector-go"
|
||||
)
|
||||
|
||||
// UpdateDocumentChunkReq 更新文件块向量请求
|
||||
type UpdateDocumentChunkReq struct {
|
||||
g.Meta `path:"/updateDocumentChunk" method:"put" tags:"文件块向量管理" summary:"更新文件块" dc:"更新文件块"`
|
||||
// RAGQueryReq RAG查询请求
|
||||
type RAGQueryReq struct {
|
||||
g.Meta `path:"/ragQuery" method:"post" tags:"RAG查询" summary:"执行RAG查询" dc:"执行RAG查询"`
|
||||
|
||||
Content string `json:"content" v:"required#查询内容不能为空" dc:"用户问题"`
|
||||
DatasetIds []int64 `json:"datasetIds" dc:"数据集ID"`
|
||||
History []*Message `json:"history" dc:"历史对话"`
|
||||
TopK int `json:"topK" d:"5" dc:"检索topK,默认5"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// RAGQueryRes RAG查询响应
|
||||
type RAGQueryRes struct {
|
||||
Answer string `json:"answer" dc:"生成的答案"`
|
||||
}
|
||||
|
||||
// UpdateDocumentVectorReq 更新文件块向量请求
|
||||
type UpdateDocumentVectorReq struct {
|
||||
g.Meta `path:"/update" 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:"分页查询文件块向量列表,支持多条件筛选"`
|
||||
// ListDocumentVectorReq 文件块向量列表请求
|
||||
type ListDocumentVectorReq struct {
|
||||
g.Meta `path:"/list" method:"get" tags:"文件块向量管理" summary:"获取文件块向量列表" dc:"分页查询文件块向量列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
@@ -28,13 +48,13 @@ type ListDocumentChunkReq struct {
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus"`
|
||||
}
|
||||
|
||||
// ListDocumentChunkRes 文件块向量列表响应
|
||||
type ListDocumentChunkRes struct {
|
||||
List []*DocumentChunkItem `json:"list"`
|
||||
Total int `json:"total"`
|
||||
// ListDocumentVectorRes 文件块向量列表响应
|
||||
type ListDocumentVectorRes struct {
|
||||
List []*DocumentVectorVO `json:"list"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type DocumentChunkItem struct {
|
||||
type DocumentVectorVO struct {
|
||||
Id int64 `json:"id,string" dc:"id"`
|
||||
Status document.Status `json:"status" dc:"状态"`
|
||||
VectorStatus document.VectorStatus `json:"vectorStatus" dc:"向量状态"`
|
||||
@@ -49,7 +69,7 @@ type DocumentChunkItem struct {
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type VectorDocumentChunkMsg struct {
|
||||
type VectorDocumentVectorMsg struct {
|
||||
TenantId uint64 `json:"tenantId"`
|
||||
Creator string `json:"creator"`
|
||||
DatasetId int64 `json:"datasetId"` // 数据集ID
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// CreateKeywordReq 创建关键词请求
|
||||
type CreateKeywordReq struct {
|
||||
g.Meta `path:"/createKeyword" method:"post" tags:"关键词管理" summary:"创建关键词" dc:"创建关键词"`
|
||||
g.Meta `path:"/create" method:"post" tags:"关键词管理" summary:"创建关键词" dc:"创建关键词"`
|
||||
|
||||
DatasetId int64 `json:"datasetId" v:"required#数据集ID不能为空"`
|
||||
DocumentId int64 `json:"documentId" v:"required#文档ID不能为空"`
|
||||
@@ -23,7 +23,7 @@ type CreateKeywordRes struct {
|
||||
|
||||
// UpdateKeywordReq 更新关键词请求
|
||||
type UpdateKeywordReq struct {
|
||||
g.Meta `path:"/updateKeyword" method:"put" tags:"关键词管理" summary:"更新关键词" dc:"更新关键词"`
|
||||
g.Meta `path:"/update" method:"put" tags:"关键词管理" summary:"更新关键词" dc:"更新关键词"`
|
||||
|
||||
Id int64 `json:"id" v:"required#ID不能为空"`
|
||||
Word string `json:"word"`
|
||||
@@ -32,21 +32,21 @@ type UpdateKeywordReq struct {
|
||||
|
||||
// DeleteKeywordReq 删除关键词请求
|
||||
type DeleteKeywordReq struct {
|
||||
g.Meta `path:"/deleteKeyword" method:"delete" tags:"关键词管理" summary:"删除关键词" dc:"删除关键词"`
|
||||
g.Meta `path:"/delete" 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:"获取关键词详情"`
|
||||
g.Meta `path:"/get" 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:"分页查询关键词列表,支持多条件筛选"`
|
||||
g.Meta `path:"/list" method:"get" tags:"关键词管理" summary:"获取关键词列表" dc:"分页查询关键词列表,支持多条件筛选"`
|
||||
|
||||
Page *beans.Page `json:"page"`
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// RAGQueryReq RAG查询请求
|
||||
type RAGQueryReq struct {
|
||||
g.Meta `path:"/ragQuery" method:"post" tags:"RAG查询" summary:"执行RAG查询" dc:"执行RAG查询"`
|
||||
|
||||
Content string `json:"content" v:"required#查询内容不能为空" dc:"用户问题"`
|
||||
DatasetIds []int64 `json:"datasetIds" dc:"数据集ID"`
|
||||
History []*Message `json:"history" dc:"历史对话"`
|
||||
TopK int `json:"topK" d:"5" dc:"检索topK,默认5"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// RAGQueryRes RAG查询响应
|
||||
type RAGQueryRes struct {
|
||||
Answer string `json:"answer" dc:"生成的答案"`
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"rag/common/task"
|
||||
"rag/consts/task"
|
||||
)
|
||||
|
||||
// WriteTaskProgressReq 写入任务进度请求
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/pgvector/pgvector-go"
|
||||
)
|
||||
|
||||
type documentChunkCol struct {
|
||||
type documentVectorCol struct {
|
||||
beans.SQLBaseCol
|
||||
Status string
|
||||
VectorStatus string
|
||||
@@ -20,7 +20,7 @@ type documentChunkCol struct {
|
||||
Metadata string
|
||||
}
|
||||
|
||||
var DocumentChunkCol = documentChunkCol{
|
||||
var DocumentVectorCol = documentVectorCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
Status: "status",
|
||||
VectorStatus: "vector_status",
|
||||
@@ -33,8 +33,8 @@ var DocumentChunkCol = documentChunkCol{
|
||||
Metadata: "metadata",
|
||||
}
|
||||
|
||||
// DocumentChunk 文档切分块实体
|
||||
type DocumentChunk struct {
|
||||
// DocumentVector 文档切分块实体
|
||||
type DocumentVector struct {
|
||||
beans.SQLBaseDO `orm:",inline"`
|
||||
|
||||
Status document.Status `orm:"status" json:"status" dc:"状态"`
|
||||
@@ -1,7 +1,7 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"rag/common/task"
|
||||
"rag/consts/task"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user