chore: replace all cn comments to en version by volc api (#313)

This commit is contained in:
tecvan
2025-07-31 15:18:11 +08:00
committed by GitHub
parent 91d6cdb430
commit 5abc63fba6
254 changed files with 5899 additions and 5844 deletions

View File

@@ -132,12 +132,12 @@ func (dao *KnowledgeDocumentDAO) DeleteDocuments(ctx context.Context, ids []int6
tx.Commit()
}
}()
// 删除document
// Delete document
err = tx.WithContext(ctx).Model(&model.KnowledgeDocument{}).Where("id in ?", ids).Delete(&model.KnowledgeDocument{}).Error
if err != nil {
return err
}
// 删除document_slice
// Delete document_slice
err = tx.WithContext(ctx).Model(&model.KnowledgeDocumentSlice{}).Where("document_id in?", ids).Delete(&model.KnowledgeDocumentSlice{}).Error
if err != nil {
return err

View File

@@ -120,7 +120,7 @@ func (dao *KnowledgeDocumentSliceDAO) listBatch(ctx context.Context, knowledgeID
pos []*model.KnowledgeDocumentSlice, hasMore bool, err error) {
if batchSize <= 0 {
batchSize = 100 // 默认批量大小
batchSize = 100 // Default batch size
}
do, err := dao.listDo(ctx, knowledgeID, documentID)
@@ -161,7 +161,7 @@ func (dao *KnowledgeDocumentSliceDAO) GetDocumentSliceIDs(ctx context.Context, d
if len(docIDs) == 0 {
return nil, errors.New("empty document ids")
}
// doc可能会有很多slice所以批量处理
// Doc may have many slices, so batch processing
sliceIDs = make([]int64, 0)
var mu sync.Mutex
errGroup, ctx := errgroup.WithContext(ctx)

View File

@@ -10,20 +10,20 @@ import (
const TableNameKnowledge = "knowledge"
// Knowledge 知识库表
// Knowledge knowledge tabke
type Knowledge struct {
ID int64 `gorm:"column:id;primaryKey;comment:主键ID" json:"id"` // 主键ID
Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称
AppID int64 `gorm:"column:app_id;not null;comment:项目ID标识该资源是否是项目独有" json:"app_id"` // 项目ID标识该资源是否是项目独有
CreatorID int64 `gorm:"column:creator_id;not null;comment:ID" json:"creator_id"` // ID
SpaceID int64 `gorm:"column:space_id;not null;comment:空间ID" json:"space_id"` // 空间ID
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time in Milliseconds" json:"deleted_at"` // Delete Time in Milliseconds
Status int32 `gorm:"column:status;not null;default:1;comment:0 初始化, 1 生效 2 失效" json:"status"` // 0 初始化, 1 生效 2 失效
Description string `gorm:"column:description;comment:描述" json:"description"` // 描述
IconURI string `gorm:"column:icon_uri;comment:头像uri" json:"icon_uri"` // 头像uri
FormatType int32 `gorm:"column:format_type;not null;comment:0:文本 1:表格 2:图片" json:"format_type"` // 0:文本 1:表格 2:图片
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
Name string `gorm:"column:name;not null;comment:knowledge's name" json:"name"` // knowledge's name
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
Status int32 `gorm:"column:status;not null;default:1;comment:0 initialization, 1 effective, 2 invalid" json:"status"` // 0 initialization, 1 effective, 2 invalid
Description string `gorm:"column:description;comment:description" json:"description"` // description
IconURI string `gorm:"column:icon_uri;comment:icon uri" json:"icon_uri"` // icon uri
FormatType int32 `gorm:"column:format_type;not null;comment:0: Text 1: Table 2: Images" json:"format_type"` // 0: Text 1: Table 2: Images
}
// TableName Knowledge's table name

View File

@@ -11,27 +11,27 @@ import (
const TableNameKnowledgeDocument = "knowledge_document"
// KnowledgeDocument 知识库文档表
// KnowledgeDocument knowledge document info
type KnowledgeDocument struct {
ID int64 `gorm:"column:id;primaryKey;comment:主键ID" json:"id"` // 主键ID
KnowledgeID int64 `gorm:"column:knowledge_id;not null;comment:所属knowledge的ID" json:"knowledge_id"` // 所属knowledge的ID
Name string `gorm:"column:name;not null;comment:文档名称" json:"name"` // 文档名称
FileExtension string `gorm:"column:file_extension;not null;default:0;comment:文档类型, txt/pdf/csv/..." json:"file_extension"` // 文档类型, txt/pdf/csv/...
DocumentType int32 `gorm:"column:document_type;not null;comment:文档类型: 0:文本 1:表格 2:图片" json:"document_type"` // 文档类型: 0:文本 1:表格 2:图片
URI string `gorm:"column:uri;comment:资源uri" json:"uri"` // 资源uri
Size int64 `gorm:"column:size;not null;comment:文档大小" json:"size"` // 文档大小
SliceCount int64 `gorm:"column:slice_count;not null;comment:分片数量" json:"slice_count"` // 分片数量
CharCount int64 `gorm:"column:char_count;not null;comment:字符数" json:"char_count"` // 字符数
CreatorID int64 `gorm:"column:creator_id;not null;comment:创建者ID" json:"creator_id"` // 创建者ID
SpaceID int64 `gorm:"column:space_id;not null;comment:空间id" json:"space_id"` // 空间id
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time in Milliseconds" json:"deleted_at"` // Delete Time in Milliseconds
SourceType int32 `gorm:"column:source_type;not null;comment:0:本地文件上传, 2:自定义文本" json:"source_type"` // 0:本地文件上传, 2:自定义文本
Status int32 `gorm:"column:status;not null;comment:状态" json:"status"` // 状态
FailReason string `gorm:"column:fail_reason;comment:失败原因" json:"fail_reason"` // 失败原因
ParseRule *DocumentParseRule `gorm:"column:parse_rule;comment:解析+切片规则;serializer:json" json:"parse_rule"` // 解析+切片规则
TableInfo *entity.TableInfo `gorm:"column:table_info;comment:表格信息;serializer:json" json:"table_info"` // 表格信息
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
KnowledgeID int64 `gorm:"column:knowledge_id;not null;comment:knowledge id" json:"knowledge_id"` // knowledge id
Name string `gorm:"column:name;not null;comment:document name" json:"name"` // document name
FileExtension string `gorm:"column:file_extension;not null;default:0;comment:Document type, txt/pdf/csv etc.." json:"file_extension"` // Document type, txt/pdf/csv etc..
DocumentType int32 `gorm:"column:document_type;not null;comment:Document type: 0: Text 1: Table 2: Image" json:"document_type"` // Document type: 0: Text 1: Table 2: Image
URI string `gorm:"column:uri;comment:uri" json:"uri"` // uri
Size int64 `gorm:"column:size;not null;comment:document size" json:"size"` // document size
SliceCount int64 `gorm:"column:slice_count;not null;comment:slice count" json:"slice_count"` // slice count
CharCount int64 `gorm:"column:char_count;not null;comment:number of characters" json:"char_count"` // number of characters
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
SourceType int32 `gorm:"column:source_type;comment:0: Local file upload, 2: Custom text, 103: Feishu 104: Lark" json:"source_type"` // 0: Local file upload, 2: Custom text, 103: Feishu 104: Lark
Status int32 `gorm:"column:status;not null;comment:status" json:"status"` // status
FailReason string `gorm:"column:fail_reason;comment:fail reason" json:"fail_reason"` // fail reason
ParseRule *DocumentParseRule `gorm:"column:parse_rule;comment:parse rule;serializer:json" json:"parse_rule"` // parse rule
TableInfo *entity.TableInfo `gorm:"column:table_info;comment:table info;serializer:json" json:"table_info"` // table info
}
// TableName KnowledgeDocument's table name

View File

@@ -10,21 +10,21 @@ import (
const TableNameKnowledgeDocumentReview = "knowledge_document_review"
// KnowledgeDocumentReview 文档审阅表
// KnowledgeDocumentReview Document slice preview info
type KnowledgeDocumentReview struct {
ID int64 `gorm:"column:id;primaryKey;comment:主键ID" json:"id"` // 主键ID
KnowledgeID int64 `gorm:"column:knowledge_id;not null;comment:knowledge id" json:"knowledge_id"` // knowledge id
SpaceID int64 `gorm:"column:space_id;not null;comment:空间id" json:"space_id"` // 空间id
Name string `gorm:"column:name;not null;comment:文档名称" json:"name"` // 文档名称
Type string `gorm:"column:type;not null;default:0;comment:文档类型" json:"type"` // 文档类型
URI string `gorm:"column:uri;comment:资源标识" json:"uri"` // 资源标识
FormatType int32 `gorm:"column:format_type;not null;comment:0 文本, 1 表格, 2 图片" json:"format_type"` // 0 文本, 1 表格, 2 图片
Status int32 `gorm:"column:status;not null;comment:0 处理中1 已完成2 失败3 失效" json:"status"` // 0 处理中1 已完成2 失败3 失效
ChunkRespURI string `gorm:"column:chunk_resp_uri;comment:预切片tos资源标识" json:"chunk_resp_uri"` // 预切片tos资源标识
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time in Milliseconds" json:"deleted_at"` // Delete Time in Milliseconds
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
CreatorID int64 `gorm:"column:creator_id;not null;comment:创建者ID" json:"creator_id"` // 创建者ID
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
KnowledgeID int64 `gorm:"column:knowledge_id;not null;comment:knowledge id" json:"knowledge_id"` // knowledge id
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
Name string `gorm:"column:name;not null;comment:name" json:"name"` // name
Type string `gorm:"column:type;not null;default:0;comment:document type" json:"type"` // document type
URI string `gorm:"column:uri;comment:uri" json:"uri"` // uri
FormatType int32 `gorm:"column:format_type;not null;comment:0 text, 1 table, 2 images" json:"format_type"` // 0 text, 1 table, 2 images
Status int32 `gorm:"column:status;not null;comment:0 Processing 1 Completed 2 Failed 3 Expired" json:"status"` // 0 Processing 1 Completed 2 Failed 3 Expired
ChunkRespURI string `gorm:"column:chunk_resp_uri;comment:pre-sliced uri" json:"chunk_resp_uri"` // pre-sliced uri
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
}
// TableName KnowledgeDocumentReview's table name

View File

@@ -10,21 +10,21 @@ import (
const TableNameKnowledgeDocumentSlice = "knowledge_document_slice"
// KnowledgeDocumentSlice 知识库文件切片表
// KnowledgeDocumentSlice knowledge document slice
type KnowledgeDocumentSlice struct {
ID int64 `gorm:"column:id;primaryKey;comment:主键ID" json:"id"` // 主键ID
KnowledgeID int64 `gorm:"column:knowledge_id;not null;comment:knowledge id" json:"knowledge_id"` // knowledge id
DocumentID int64 `gorm:"column:document_id;not null;comment:document id" json:"document_id"` // document id
Content string `gorm:"column:content;comment:切片内容" json:"content"` // 切片内容
Sequence float64 `gorm:"column:sequence;not null;type:decimal(20,5);comment:切片顺序号, 从1开始" json:"sequence"` // 切片顺序号, 从1开始
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time in Milliseconds" json:"deleted_at"` // Delete Time in Milliseconds
CreatorID int64 `gorm:"column:creator_id;not null;comment:创建者ID" json:"creator_id"` // 创建者ID
SpaceID int64 `gorm:"column:space_id;not null;comment:空间ID" json:"space_id"` // 空间ID
Status int32 `gorm:"column:status;not null;comment:状态" json:"status"` // 状态
FailReason string `gorm:"column:fail_reason;comment:失败原因" json:"fail_reason"` // 失败原因
Hit int64 `gorm:"column:hit;not null;comment:命中次数" json:"hit"` // 命中次数
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
KnowledgeID int64 `gorm:"column:knowledge_id;not null;comment:knowledge id" json:"knowledge_id"` // knowledge id
DocumentID int64 `gorm:"column:document_id;not null;comment:document_id" json:"document_id"` // document_id
Content string `gorm:"column:content;comment:content" json:"content"` // content
Sequence float64 `gorm:"column:sequence;not null;comment:slice sequence number, starting from 1" json:"sequence"` // slice sequence number, starting from 1
CreatedAt int64 `gorm:"column:created_at;not null;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
UpdatedAt int64 `gorm:"column:updated_at;not null;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
Status int32 `gorm:"column:status;not null;comment:status" json:"status"` // status
FailReason string `gorm:"column:fail_reason;comment:fail reason" json:"fail_reason"` // fail reason
Hit int64 `gorm:"column:hit;not null;comment:hit counts" json:"hit"` // hit counts
}
// TableName KnowledgeDocumentSlice's table name

View File

@@ -45,23 +45,23 @@ func newKnowledge(db *gorm.DB, opts ...gen.DOOption) knowledge {
return _knowledge
}
// knowledge 知识库表
// knowledge knowledge tabke
type knowledge struct {
knowledgeDo
ALL field.Asterisk
ID field.Int64 // 主键ID
Name field.String // 名称
AppID field.Int64 // 项目ID标识该资源是否是项目独有
CreatorID field.Int64 // ID
SpaceID field.Int64 // 空间ID
ID field.Int64 // id
Name field.String // knowledge's name
AppID field.Int64 // app id
CreatorID field.Int64 // creator id
SpaceID field.Int64 // space id
CreatedAt field.Int64 // Create Time in Milliseconds
UpdatedAt field.Int64 // Update Time in Milliseconds
DeletedAt field.Field // Delete Time in Milliseconds
Status field.Int32 // 0 初始化, 1 生效 2 失效
Description field.String // 描述
IconURI field.String // 头像uri
FormatType field.Int32 // 0:文本 1:表格 2:图片
DeletedAt field.Field // Delete Time
Status field.Int32 // 0 initialization, 1 effective, 2 invalid
Description field.String // description
IconURI field.String // icon uri
FormatType field.Int32 // 0: Text 1: Table 2: Images
fieldMap map[string]field.Expr
}

View File

@@ -52,30 +52,30 @@ func newKnowledgeDocument(db *gorm.DB, opts ...gen.DOOption) knowledgeDocument {
return _knowledgeDocument
}
// knowledgeDocument 知识库文档表
// knowledgeDocument knowledge document info
type knowledgeDocument struct {
knowledgeDocumentDo
ALL field.Asterisk
ID field.Int64 // 主键ID
KnowledgeID field.Int64 // 所属knowledge的ID
Name field.String // 文档名称
FileExtension field.String // 文档类型, txt/pdf/csv/...
DocumentType field.Int32 // 文档类型: 0:文本 1:表格 2:图片
URI field.String // 资源uri
Size field.Int64 // 文档大小
SliceCount field.Int64 // 分片数量
CharCount field.Int64 // 字符数
CreatorID field.Int64 // 创建者ID
SpaceID field.Int64 // 空间id
ID field.Int64 // id
KnowledgeID field.Int64 // knowledge id
Name field.String // document name
FileExtension field.String // Document type, txt/pdf/csv etc..
DocumentType field.Int32 // Document type: 0: Text 1: Table 2: Image
URI field.String // uri
Size field.Int64 // document size
SliceCount field.Int64 // slice count
CharCount field.Int64 // number of characters
CreatorID field.Int64 // creator id
SpaceID field.Int64 // space id
CreatedAt field.Int64 // Create Time in Milliseconds
UpdatedAt field.Int64 // Update Time in Milliseconds
DeletedAt field.Field // Delete Time in Milliseconds
SourceType field.Int32 // 0:本地文件上传, 2:自定义文本
Status field.Int32 // 状态
FailReason field.String // 失败原因
ParseRule field.Field // 解析+切片规则
TableInfo field.Field // 表格信息
DeletedAt field.Field // Delete Time
SourceType field.Int32 // 0: Local file upload, 2: Custom text, 103: Feishu 104: Lark
Status field.Int32 // status
FailReason field.String // fail reason
ParseRule field.Field // parse rule
TableInfo field.Field // table info
fieldMap map[string]field.Expr
}

View File

@@ -46,24 +46,24 @@ func newKnowledgeDocumentReview(db *gorm.DB, opts ...gen.DOOption) knowledgeDocu
return _knowledgeDocumentReview
}
// knowledgeDocumentReview 文档审阅表
// knowledgeDocumentReview Document slice preview info
type knowledgeDocumentReview struct {
knowledgeDocumentReviewDo
ALL field.Asterisk
ID field.Int64 // 主键ID
ID field.Int64 // id
KnowledgeID field.Int64 // knowledge id
SpaceID field.Int64 // 空间id
Name field.String // 文档名称
Type field.String // 文档类型
URI field.String // 资源标识
FormatType field.Int32 // 0 文本, 1 表格, 2 图片
Status field.Int32 // 0 处理中1 已完成2 失败3 失效
ChunkRespURI field.String // 预切片tos资源标识
DeletedAt field.Field // Delete Time in Milliseconds
SpaceID field.Int64 // space id
Name field.String // name
Type field.String // document type
URI field.String // uri
FormatType field.Int32 // 0 text, 1 table, 2 images
Status field.Int32 // 0 Processing 1 Completed 2 Failed 3 Expired
ChunkRespURI field.String // pre-sliced uri
DeletedAt field.Field // Delete Time
CreatedAt field.Int64 // Create Time in Milliseconds
UpdatedAt field.Int64 // Update Time in Milliseconds
CreatorID field.Int64 // 创建者ID
CreatorID field.Int64 // creator id
fieldMap map[string]field.Expr
}

View File

@@ -46,24 +46,24 @@ func newKnowledgeDocumentSlice(db *gorm.DB, opts ...gen.DOOption) knowledgeDocum
return _knowledgeDocumentSlice
}
// knowledgeDocumentSlice 知识库文件切片表
// knowledgeDocumentSlice knowledge document slice
type knowledgeDocumentSlice struct {
knowledgeDocumentSliceDo
ALL field.Asterisk
ID field.Int64 // 主键ID
ID field.Int64 // id
KnowledgeID field.Int64 // knowledge id
DocumentID field.Int64 // document id
Content field.String // 切片内容
Sequence field.Float64 // 切片顺序号, 从1开始
DocumentID field.Int64 // document_id
Content field.String // content
Sequence field.Float64 // slice sequence number, starting from 1
CreatedAt field.Int64 // Create Time in Milliseconds
UpdatedAt field.Int64 // Update Time in Milliseconds
DeletedAt field.Field // Delete Time in Milliseconds
CreatorID field.Int64 // 创建者ID
SpaceID field.Int64 // 空间ID
Status field.Int32 // 状态
FailReason field.String // 失败原因
Hit field.Int64 // 命中次数
DeletedAt field.Field // Delete Time
CreatorID field.Int64 // creator id
SpaceID field.Int64 // space id
Status field.Int32 // status
FailReason field.String // fail reason
Hit field.Int64 // hit counts
fieldMap map[string]field.Expr
}