1
import { z } from 'zod';
3
import { FileParsingTask } from '@/types/asyncTask';
5
export interface FileUploadState {
12
* upload speed in Byte/s
17
export type FileUploadStatus = 'pending' | 'uploading' | 'processing' | 'success' | 'error';
19
export type FileProcessStatus = 'pending' | 'chunking' | 'embedding' | 'success' | 'error';
21
export const UPLOAD_STATUS_SET = new Set(['uploading', 'pending', 'processing']);
23
// the file that is upload at chat page
24
export interface UploadFileItem {
26
* base64 data, it will use in other data
31
* the file url after upload,it will be s3 url
32
* if enable the S3 storage, or the data is same as base64Url
37
* blob url for local preview
38
* it will use in the file preview before send the message
41
status: FileUploadStatus;
42
tasks?: FileParsingTask;
43
uploadState?: FileUploadState;
46
export const FileMetadataSchema = z.object({
53
export type FileMetadata = z.infer<typeof FileMetadataSchema>;
55
export const UploadFileSchema = z.object({
56
data: z.instanceof(ArrayBuffer).optional(),
59
* @example 'image/png'
62
// TODO: Need be required
63
hash: z.string().optional(),
65
knowledgeBaseId: z.string().optional(),
67
metadata: z.any().optional(),
76
* the mode database save the file
77
* local mean save the raw file into data
78
* url mean upload the file to a cdn and then save the url
80
saveMode: z.enum(['local', 'url']),
86
* file url if saveMode is url
88
url: z.string().optional(),
91
export type UploadFileParams = z.infer<typeof UploadFileSchema>;