Files
botsmann/types/document.ts
T
g-butandClaude Opus 4.5 403c9bf5a7 Add Phase 3: Document upload and RAG chat
- Add Transformers.js for local embeddings generation
- Create document upload API with Supabase Storage
- Create document processing pipeline (parse, chunk, embed)
- Create semantic search API using pgvector
- Create RAG chat API combining search + LLM
- Add documents page UI with upload, process, and chat
- Add database migration for document status columns
- Configure Next.js to externalize ONNX packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 12:39:43 +01:00

68 lines
1.3 KiB
TypeScript

/**
* Document types for the RAG system
*/
export interface Document {
id: string;
user_id: string;
name: string;
type: string;
size_bytes: number;
storage_path: string;
status: 'pending' | 'processing' | 'ready' | 'error';
error_message?: string;
chunk_count?: number;
created_at: string;
updated_at: string;
}
export interface DocumentChunk {
id: string;
document_id: string;
user_id: string;
content: string;
embedding: number[];
metadata: {
chunk_index: number;
start_char?: number;
end_char?: number;
};
created_at: string;
}
export interface DocumentUploadResponse {
success: boolean;
document?: Document;
error?: string;
}
export interface DocumentListResponse {
success: boolean;
documents?: Document[];
error?: string;
}
export interface DocumentSearchResult {
chunk_id: string;
document_id: string;
document_name: string;
content: string;
similarity: number;
}
export interface SearchResponse {
success: boolean;
results?: DocumentSearchResult[];
error?: string;
}
export type SupportedFileType = 'text/plain' | 'text/markdown' | 'application/pdf';
export const SUPPORTED_FILE_TYPES: SupportedFileType[] = [
'text/plain',
'text/markdown',
'application/pdf',
];
export const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB