| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- export interface IndexingConfig {
- chunkSize: number;
- chunkOverlap: number;
- embeddingModelId: string;
- mode?: 'fast' | 'precise'; // Processing mode: fast/precise
- groupIds?: string[]; // Groups to associate with the file upon upload
- }
- // Vision Pipeline 相关类型
- export interface VisionAnalysisResult {
- text: string; // Extracted text content
- images: ImageDescription[]; // Image descriptions
- layout: string; // Layout type
- confidence: number; // 信頼度 (0-1)
- pageIndex?: number; // Page number
- }
- export interface ImageDescription {
- type: string; // Image type (graph/diagram/flowchart etc.)
- description: string; // Detailed description
- position?: number; // Position within the page
- }
- export interface PipelineResult {
- success: boolean;
- fileId: string;
- fileName: string;
- totalPages: number;
- processedPages: number;
- failedPages: number;
- results: VisionAnalysisResult[];
- cost: number; // Cost (USD)
- duration: number; // Duration (seconds)
- mode: 'precise';
- }
- export interface ModeRecommendation {
- recommendedMode: 'precise' | 'fast';
- reason: string;
- estimatedCost?: number; // Estimated cost (USD)
- estimatedTime?: number; // Estimated time (seconds)
- warnings?: string[];
- }
- // Type definitions for knowledge base extensions
- export interface KnowledgeGroup {
- id: string;
- name: string;
- description?: string;
- color: string;
- fileCount: number;
- parentId?: string | null;
- children?: KnowledgeGroup[];
- createdAt: string;
- updatedAt?: string;
- }
- export interface CreateGroupData {
- name: string;
- description?: string;
- color?: string;
- parentId?: string | null;
- }
- export interface UpdateGroupData {
- name?: string;
- description?: string;
- color?: string;
- parentId?: string | null;
- }
- export interface KnowledgeFile {
- id: string;
- name: string;
- originalName: string;
- size: number;
- type: string;
- status: 'pending' | 'indexing' | 'extracted' | 'vectorized' | 'failed' | 'ready' | 'error';
- groups?: KnowledgeGroup[];
- createdAt: string;
- updatedAt: string;
- }
- export interface SearchHistoryItem {
- id: string;
- title: string;
- selectedGroups: string[] | null;
- messageCount: number;
- lastMessageAt: string;
- createdAt: string;
- }
- export interface SearchHistoryDetail {
- id: string;
- title: string;
- selectedGroups: string[] | null;
- messages: Array<{
- id: string;
- role: 'user' | 'assistant';
- content: string;
- sources?: Array<{
- fileName: string;
- content: string;
- score: number;
- chunkIndex: number;
- }>;
- createdAt: string;
- }>;
- }
- export interface PDFStatus {
- status: 'pending' | 'converting' | 'ready' | 'failed';
- pdfPath?: string;
- error?: string;
- }
- export interface NoteCategory {
- id: string
- name: string
- parentId?: string
- level: number
- userId: string
- tenantId: string
- createdAt: string
- updatedAt: string
- }
- export interface Note {
- id: string;
- title: string;
- content: string;
- userId: string;
- tenantId?: string;
- groupId?: string;
- categoryId?: string;
- sharingStatus: 'PRIVATE' | 'TENANT' | 'GLOBAL_PENDING' | 'GLOBAL_APPROVED';
- createdAt: string;
- updatedAt: string;
- user?: {
- id: string;
- username: string;
- name?: string;
- };
- }
- export interface RawFile {
- name: string;
- type: string;
- size: number;
- content: string;
- preview?: string;
- file: File; // Keep original file for upload
- isNote?: boolean;
- textContent?: string;
- }
- export enum Role {
- USER = 'user',
- MODEL = 'model',
- }
- export interface Message {
- id: string;
- role: Role;
- text: string;
- timestamp: number;
- isError?: boolean;
- sources?: ChatSource[];
- }
- export interface ChatSource {
- fileName: string;
- title?: string;
- content: string;
- score: number;
- chunkIndex: number;
- fileId?: string;
- }
- export interface ChatState {
- messages: Message[];
- isLoading: boolean;
- }
- export type Language = 'ja' | 'en' | 'zh';
- export enum ModelType {
- // Changed from type to enum
- LLM = "llm",
- EMBEDDING = "embedding",
- RERANK = "rerank",
- VISION = "vision",
- }
- // 1. Model Definition (The "Provider" setup)
- export interface ModelConfig {
- id: string;
- name: string; // Display name, e.g. "My DeepSeek"
- modelId: string; // The actual string ID sent to API, e.g., "gpt-4o"
- baseUrl?: string; // Base URL for OpenAI compatible API
- apiKey?: string; // API key for the service
- type: ModelType;
- dimensions?: number; // Vector dimensions of the embedding model
- supportsVision?: boolean; // Whether it supports vision capabilities
- // ==================== Additional Fields ====================
- /**
- * Model's input token limit
- * e.g., OpenAI=8191, Gemini=2048
- */
- maxInputTokens?: number;
- /**
- * Batch processing limit (maximum number of inputs per request)
- * e.g., OpenAI=2048, Gemini=100
- */
- maxBatchSize?: number;
- /**
- * Whether it is a vector model (for identification in system settings)
- */
- isVectorModel?: boolean;
- /**
- * Model provider name (for display)
- * e.g., "OpenAI", "Google Gemini", "Custom"
- */
- providerName?: string;
- /**
- * Whether it is enabled
- */
- isEnabled?: boolean;
- /**
- * Whether to use this model as the default
- */
- isDefault?: boolean;
- }
- // 2. Application Logic Settings (The "App" setup)
- export interface AppSettings {
- // References to ModelConfig IDs
- selectedLLMId: string;
- selectedEmbeddingId: string; // Default for new uploads, and used for query encoding
- selectedRerankId: string;
- // Model Hyperparameters
- temperature: number;
- maxTokens: number;
- // Retrieval
- enableRerank: boolean;
- topK: number;
- similarityThreshold: number; // Similarity threshold for vector search
- rerankSimilarityThreshold: number; // Similarity threshold for reranking
- enableFullTextSearch: boolean; // Whether to enable full-text search
- hybridVectorWeight: number; // Vector weight for hybrid search
- // Search Enhancement
- enableQueryExpansion: boolean;
- enableHyDE: boolean;
- chunkSize?: number;
- chunkOverlap?: number;
- // Language
- language?: string;
- // Coach
- coachKbId?: string;
- // Vision
- selectedVisionId?: string;
- }
- // Default Models (Frontend specific)
- export const DEFAULT_MODELS: ModelConfig[] = [];
- export const DEFAULT_SETTINGS: AppSettings = {
- selectedLLMId: '',
- selectedEmbeddingId: '',
- selectedRerankId: '',
- temperature: 0.3,
- maxTokens: 8192,
- enableRerank: false,
- topK: 4,
- similarityThreshold: 0.3, // Default similarity threshold for vector search
- rerankSimilarityThreshold: 0.5, // Default similarity threshold for reranking
- enableFullTextSearch: false, // Turn off full-text search by default
- hybridVectorWeight: 0.7, // Vector weight for hybrid search
- enableQueryExpansion: false,
- enableHyDE: false,
- chunkSize: 1000,
- chunkOverlap: 100,
- language: 'ja',
- };
- export const API_BASE_URL = '/api'
- export interface Tenant {
- id: string;
- name: string;
- domain?: string;
- parentId?: string | null;
- children?: Tenant[];
- members?: TenantMember[];
- settings_obj?: any;
- createdAt: string;
- updatedAt: string;
- }
- export interface TenantMember {
- id: string;
- userId: string;
- tenantId: string;
- role: string;
- user?: {
- id: string;
- username: string;
- displayName?: string;
- email?: string;
- };
- createdAt: string;
- updatedAt: string;
- }
|