feat(client): enhance knowledge file upload with process configuration support
- Updated the `CreateKnowledgeFromFile` function to accept an optional `processConfig` parameter for per-upload parse configuration overrides. - Introduced the `KnowledgeProcessOverrides` type to define various parsing settings, including parser engine rules and chunking configurations. - Modified the API client and related components to handle the new process configuration, improving flexibility in knowledge file uploads. - Updated documentation and API specifications to reflect the new `process_config` parameter in the upload process. - Added a new `UploadConfirmHost` component to facilitate user confirmation for uploads, integrating with the updated upload logic. - Enhanced user experience by providing detailed configuration options during the upload process.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess'
|
||||
|
||||
export type UploadConfirmMode = 'file' | 'url' | 'manual'
|
||||
|
||||
export interface UploadConfirmManualSource {
|
||||
kbId: string
|
||||
knowledgeId?: string
|
||||
title: string
|
||||
content: string
|
||||
tagId?: string
|
||||
}
|
||||
|
||||
export interface UploadConfirmResult {
|
||||
processConfig: KnowledgeProcessOverrides
|
||||
mode: UploadConfirmMode
|
||||
files?: File[]
|
||||
urls?: string[]
|
||||
manual?: UploadConfirmManualSource
|
||||
}
|
||||
|
||||
export interface OpenUploadConfirmOptions {
|
||||
mode: UploadConfirmMode
|
||||
kbInfo: any
|
||||
files?: File[]
|
||||
urls?: string[]
|
||||
manual?: UploadConfirmManualSource
|
||||
acceptFileTypes?: string
|
||||
supportedFileTypes?: string[]
|
||||
}
|
||||
|
||||
export const useUploadConfirmStore = defineStore('uploadConfirm', {
|
||||
state: () => ({
|
||||
visible: false,
|
||||
mode: 'file' as UploadConfirmMode,
|
||||
kbInfo: null as any,
|
||||
files: [] as File[],
|
||||
urls: [] as string[],
|
||||
manual: null as UploadConfirmManualSource | null,
|
||||
acceptFileTypes: '',
|
||||
supportedFileTypes: [] as string[],
|
||||
pendingResolve: null as ((value: UploadConfirmResult) => void) | null,
|
||||
pendingReject: null as (() => void) | null,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
open(options: OpenUploadConfirmOptions): Promise<UploadConfirmResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.visible = true
|
||||
this.mode = options.mode
|
||||
this.kbInfo = options.kbInfo
|
||||
this.files = options.files ? [...options.files] : []
|
||||
this.urls = options.urls ? [...options.urls] : []
|
||||
this.manual = options.manual || null
|
||||
this.acceptFileTypes = options.acceptFileTypes || ''
|
||||
this.supportedFileTypes = options.supportedFileTypes ? [...options.supportedFileTypes] : []
|
||||
this.pendingResolve = resolve
|
||||
this.pendingReject = reject
|
||||
})
|
||||
},
|
||||
|
||||
resolveConfirm(payload: UploadConfirmResult) {
|
||||
this.pendingResolve?.(payload)
|
||||
this.reset()
|
||||
},
|
||||
|
||||
rejectConfirm() {
|
||||
this.pendingReject?.()
|
||||
this.reset()
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.visible = false
|
||||
this.mode = 'file'
|
||||
this.kbInfo = null
|
||||
this.files = []
|
||||
this.urls = []
|
||||
this.manual = null
|
||||
this.acceptFileTypes = ''
|
||||
this.supportedFileTypes = []
|
||||
this.pendingResolve = null
|
||||
this.pendingReject = null
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user