feat(avatar): show multi-file knowledge upload progress
This commit is contained in:
@@ -306,6 +306,8 @@ export interface KnowledgeDoc {
|
||||
embeddingModel?: string
|
||||
chunkCount?: number
|
||||
errorMessage?: string
|
||||
indexStage?: string
|
||||
indexProgress?: number
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
@@ -332,12 +334,18 @@ export const getKnowledgeDocs = (avatarId: string) =>
|
||||
request.get<KnowledgeDoc[]>(`/avatar/${avatarId}/knowledge/docs`)
|
||||
|
||||
// 上传文档(支持 md/txt/pdf/doc/docx/xlsx)
|
||||
export const uploadKnowledgeDoc = (avatarId: string, file: File) => {
|
||||
export const uploadKnowledgeDoc = (
|
||||
avatarId: string,
|
||||
file: File,
|
||||
onUploadProgress?: (loaded: number, total: number) => void
|
||||
) => {
|
||||
const form = new FormData()
|
||||
form.append('file', file)
|
||||
return request.post<KnowledgeDoc>(`/avatar/${avatarId}/knowledge/docs`, form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120000
|
||||
// A slow mobile uplink must not be mistaken for a failed upload.
|
||||
timeout: 10 * 60 * 1000,
|
||||
onUploadProgress: (event) => onUploadProgress?.(event.loaded, event.total || file.size)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user