Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 300 additions & 4 deletions backend/docs/docs.go

Large diffs are not rendered by default.

304 changes: 300 additions & 4 deletions backend/docs/swagger.json

Large diffs are not rendered by default.

198 changes: 198 additions & 0 deletions backend/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3139,6 +3139,40 @@ definitions:
- data
- errorMsg
type: object
FileEmbeddingSkipResponse:
properties:
fileID:
type: string
reason:
type: string
required:
- fileID
- reason
type: object
FileEmbeddingSubmissionResponse:
properties:
skipped:
items:
$ref: '#/definitions/FileEmbeddingSkipResponse'
type: array
submittedFileIDs:
items:
type: string
type: array
required:
- skipped
- submittedFileIDs
type: object
FileEmbeddingSubmissionResponseDoc:
properties:
data:
$ref: '#/definitions/FileEmbeddingSubmissionResponse'
errorMsg:
type: string
required:
- data
- errorMsg
type: object
FileListResponse:
properties:
quota:
Expand Down Expand Up @@ -3166,6 +3200,8 @@ definitions:
type: object
FileObjectResponse:
properties:
canVectorize:
type: boolean
chunkCount:
type: integer
createdAt:
Expand Down Expand Up @@ -3214,7 +3250,10 @@ definitions:
type: string
updatedAt:
type: string
vectorizationReason:
type: string
required:
- canVectorize
- chunkCount
- createdAt
- detectedMIME
Expand All @@ -3237,9 +3276,12 @@ definitions:
- sizeBytes
- status
- updatedAt
- vectorizationReason
type: object
FileProcessingStatusResponse:
properties:
canVectorize:
type: boolean
chunkCount:
type: integer
completedAt:
Expand Down Expand Up @@ -3284,7 +3326,10 @@ definitions:
x-omitempty: false
updatedAt:
type: string
vectorizationReason:
type: string
required:
- canVectorize
- chunkCount
- completedAt
- detectedMIME
Expand All @@ -3305,6 +3350,7 @@ definitions:
- ragReason
- startedAt
- updatedAt
- vectorizationReason
type: object
FileUpdateResponseDoc:
properties:
Expand Down Expand Up @@ -3758,6 +3804,40 @@ definitions:
required:
- file
type: object
KnowledgeBaseFileEmbeddingSkipResponse:
properties:
fileID:
type: string
reason:
type: string
required:
- fileID
- reason
type: object
KnowledgeBaseFileEmbeddingSubmissionResponse:
properties:
skipped:
items:
$ref: '#/definitions/KnowledgeBaseFileEmbeddingSkipResponse'
type: array
submittedFileIDs:
items:
type: string
type: array
required:
- skipped
- submittedFileIDs
type: object
KnowledgeBaseFileEmbeddingSubmissionResponseDoc:
properties:
data:
$ref: '#/definitions/KnowledgeBaseFileEmbeddingSubmissionResponse'
errorMsg:
type: string
required:
- data
- errorMsg
type: object
KnowledgeBaseFileMutationDataResponse:
properties:
updated:
Expand Down Expand Up @@ -3809,12 +3889,18 @@ definitions:
type: object
KnowledgeBaseFileProcessingStatusResponse:
properties:
canVectorize:
type: boolean
chunkCount:
type: integer
detectedMIME:
type: string
embedError:
type: string
embedStatus:
type: string
extractStatus:
type: string
fileCategory:
type: string
fileID:
Expand All @@ -3829,28 +3915,40 @@ definitions:
type: boolean
updatedAt:
type: string
vectorizationReason:
type: string
required:
- canVectorize
- chunkCount
- detectedMIME
- embedError
- embedStatus
- extractStatus
- fileCategory
- fileID
- processing
- processingReady
- processingStatus
- ragOptOut
- updatedAt
- vectorizationReason
type: object
KnowledgeBaseFileResponse:
properties:
canVectorize:
type: boolean
chunkCount:
type: integer
createdAt:
type: string
detectedMIME:
type: string
embedError:
type: string
embedStatus:
type: string
extractStatus:
type: string
fileCategory:
type: string
fileID:
Expand All @@ -3871,11 +3969,16 @@ definitions:
type: integer
updatedAt:
type: string
vectorizationReason:
type: string
required:
- canVectorize
- chunkCount
- createdAt
- detectedMIME
- embedError
- embedStatus
- extractStatus
- fileCategory
- fileID
- fileName
Expand All @@ -3886,6 +3989,7 @@ definitions:
- ragOptOut
- sizeBytes
- updatedAt
- vectorizationReason
type: object
KnowledgeBaseFileResponseDoc:
properties:
Expand Down Expand Up @@ -7459,6 +7563,28 @@ definitions:
- usedBytes
- userID
type: object
SubmitFileEmbeddingsRequest:
properties:
fileIDs:
items:
type: string
maxItems: 100
minItems: 1
type: array
required:
- fileIDs
type: object
SubmitPlatformFileEmbeddingsRequest:
properties:
fileIDs:
items:
type: string
maxItems: 100
minItems: 1
type: array
required:
- fileIDs
type: object
SubscribeRequest:
properties:
cycles:
Expand Down Expand Up @@ -11387,6 +11513,42 @@ paths:
summary: 获取平台资料内容
tags:
- admin-knowledge-bases
/admin/knowledge-bases/files/embeddings:
post:
consumes:
- application/json
description: 为管理员选中的平台资料提交向量化任务,最多100个;重复提交会幂等跳过
parameters:
- description: 平台资料ID,最多100个
in: body
name: request
required: true
schema:
$ref: '#/definitions/SubmitPlatformFileEmbeddingsRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/KnowledgeBaseFileEmbeddingSubmissionResponseDoc'
"400":
description: Bad Request
schema:
$ref: '#/definitions/KnowledgebaseErrorDoc'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/KnowledgebaseErrorDoc'
"503":
description: Service Unavailable
schema:
$ref: '#/definitions/KnowledgebaseErrorDoc'
security:
- BearerAuth: []
summary: 批量提交平台资料向量化
tags:
- admin-knowledge-bases
/admin/llm/icon-assets:
get:
description: 分页查询仍在图标库中的已上传图标,按上传时间倒序返回
Expand Down Expand Up @@ -17296,6 +17458,42 @@ paths:
summary: 获取文件内容
tags:
- chat
/files/embeddings:
post:
consumes:
- application/json
description: 为当前用户已完成文本提取的文件提交向量化任务,最多100个;重复提交会幂等跳过
parameters:
- description: 文件ID,最多100个
in: body
name: request
required: true
schema:
$ref: '#/definitions/SubmitFileEmbeddingsRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/FileEmbeddingSubmissionResponseDoc'
"400":
description: Bad Request
schema:
$ref: '#/definitions/ConversationErrorDoc'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/ConversationErrorDoc'
"503":
description: Service Unavailable
schema:
$ref: '#/definitions/ConversationErrorDoc'
security:
- BearerAuth: []
summary: 批量提交指定文件向量化
tags:
- chat
/files/processing/statuses:
post:
consumes:
Expand Down
1 change: 1 addition & 0 deletions backend/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ func NewApp() (*App, error) {
knowledgeBaseService.SetFileCleaner(conversationService)
knowledgeBaseService.SetFileContentOpener(conversationService)
knowledgeBaseService.SetFileUploader(conversationService)
knowledgeBaseService.SetFileEmbeddingSubmitter(processingService)
knowledgeBaseService.SetLogger(log)
conversationService.SetKnowledgeBaseResolver(knowledgeBaseService)
knowledgeBaseHandler := knowledgebasehttp.NewHandler(knowledgeBaseService, runtimeCfg)
Expand Down
20 changes: 20 additions & 0 deletions backend/internal/application/conversation/service_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"strings"

appembedding "github.com/DEEIX-AI/DEEIX-Chat/backend/internal/application/embedding"
appupload "github.com/DEEIX-AI/DEEIX-Chat/backend/internal/application/upload"
model "github.com/DEEIX-AI/DEEIX-Chat/backend/internal/domain/conversation"
"github.com/DEEIX-AI/DEEIX-Chat/backend/internal/repository"
Expand Down Expand Up @@ -52,6 +53,25 @@ func (s *Service) ListFiles(
return s.uploadSvc.ListFiles(ctx, userID, page, pageSize, searchQuery, filterKind, sortBy)
}

// SubmitFileEmbeddings 提交当前用户指定文件的向量化任务。
func (s *Service) SubmitFileEmbeddings(ctx context.Context, userID uint, fileIDs []string) (appembedding.TargetedSubmissionResult, error) {
if s.processingSvc == nil {
return appembedding.TargetedSubmissionResult{}, appembedding.ErrEmbeddingServiceNotConfigured
}
return s.processingSvc.SubmitFileEmbeddings(ctx, userID, fileIDs)
}

// ResolveFileVectorizationCapabilities 返回文件显式向量化能力的后端事实状态。
func (s *Service) ResolveFileVectorizationCapabilities(
ctx context.Context,
files []model.FileObject,
) map[string]appembedding.FileVectorizationCapability {
if s.processingSvc == nil {
return map[string]appembedding.FileVectorizationCapability{}
}
return s.processingSvc.ResolveFileVectorizationCapabilities(ctx, files)
}

// UploadFile 上传文件并扣减用户配额。
func (s *Service) UploadFile(ctx context.Context, input appupload.UploadFileInput) (*appupload.UploadFileResult, error) {
return s.uploadSvc.UploadFile(ctx, input)
Expand Down
Loading
Loading