export interface IndexingConfig { chunkSize: number; chunkOverlap: number; embeddingModelId: string; mode?: 'fast' | 'precise'; // 処理モード:高速/精密 } // Vision Pipeline 相关类型 export interface VisionAnalysisResult { text: string; // 抽出されたテキスト内容 images: ImageDescription[]; // 画像の説明 layout: string; // レイアウトタイプ confidence: number; // 信頼度 (0-1) pageIndex?: number; // ページ番号 } export interface ImageDescription { type: string; // 画像タイプ (グラフ/構成図/フローチャートなど) description: string; // 詳細な説明 position?: number; // ページ内の位置 } export interface PipelineResult { success: boolean; fileId: string; fileName: string; totalPages: number; processedPages: number; failedPages: number; results: VisionAnalysisResult[]; cost: number; // コスト(ドル) duration: number; // 所要時間(秒) mode: 'precise'; } export interface ModeRecommendation { recommendedMode: 'precise' | 'fast'; reason: string; estimatedCost?: number; // 推定コスト(ドル) estimatedTime?: number; // 推定時間(秒) warnings?: string[]; } // ナレッジベース拡張機能の型定義 export interface KnowledgeGroup { id: string; name: string; description?: string; color: string; fileCount: number; createdAt: string; updatedAt?: string; } export interface CreateGroupData { name: string; description?: string; color?: string; } export interface UpdateGroupData { name?: string; description?: string; color?: 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 KnowledgeFile { id: string; name: string; type: string; size: number; content: string; // Base64 string preview?: string; // For images uploadDate: number; status: 'pending' | 'indexing' | 'extracted' | 'vectorized' | 'failed' | 'ready' | 'error'; // Keep 'ready'/'error' for backward compatibility if needed indexingConfig: IndexingConfig; groups?: KnowledgeGroup[]; // ファイルが所属するグループ pdfPath?: string; // PDFプレビューパス } 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; 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; // 埋め込みモデルのベクトル次元 supportsVision?: boolean; // 視覚能力をサポートするかどうか // ==================== 追加フィールド ==================== /** * モデルの入力トークン制限 * 例: OpenAI=8191, Gemini=2048 */ maxInputTokens?: number; /** * バッチ処理制限(1回のリクエストあたりの最大入力数) * 例: OpenAI=2048, Gemini=100 */ maxBatchSize?: number; /** * ベクトルモデルかどうか(システム設定での識別用) */ isVectorModel?: boolean; /** * モデルプロバイダー名(表示用) * 例: "OpenAI", "Google Gemini", "カスタム" */ providerName?: string; /** * 有効かどうか */ isEnabled?: boolean; /** * このモデルをデフォルトとして使用するかどうか */ 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; // ベクトル検索の類似度しきい値 rerankSimilarityThreshold: number; // リランクの類似度しきい値 enableFullTextSearch: boolean; // 全文検索を有効にするかどうか hybridVectorWeight: number; // ハイブリッド検索のベクトル重み // Search Enhancement enableQueryExpansion: boolean; enableHyDE: boolean; // Language language?: string; // Coach coachKbId?: 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, // デフォルトのベクトル検索類似度しきい値 rerankSimilarityThreshold: 0.5, // デフォルトのリランク類似度しきい値 enableFullTextSearch: false, // デフォルトで全文検索をオフにする hybridVectorWeight: 0.7, // ハイブリッド検索のベクトル重み enableQueryExpansion: false, enableHyDE: false, language: 'ja', }; export const API_BASE_URL = '/api'