| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- 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;
- intro?: string;
- }
- export interface CreateGroupData {
- name: string;
- description?: string;
- intro?: string;
- color?: string;
- }
- export interface UpdateGroupData {
- name?: string;
- description?: string;
- intro?: 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;
- pageNumber?: number; // 追加
- }>;
- createdAt: string;
- }>;
- }
- export interface PDFStatus {
- status: 'pending' | 'converting' | 'ready' | 'failed';
- pdfPath?: string;
- error?: string;
- }
- export interface KnowledgeFile {
- id: string;
- name: string;
- title?: 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;
- pageNumber?: 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',
- }
- // 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;
- supportsVision?: boolean;
- dimensions?: number; // 嵌入模型的向量维度
- // ==================== 新增字段 ====================
- /**
- * 模型输入token限制
- * 例如: OpenAI=8191, Gemini=2048
- */
- maxInputTokens?: number;
- /**
- * 批量处理限制(一次请求最多多少个输入)
- * 例如: 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;
- scoreThreshold: number;
- similarityThreshold: number; // 相似度阈值
- enableFullTextSearch?: boolean; // 是否启用全文检索
- enableQueryExpansion?: boolean; // 是否启用查询扩展
- enableHyDE?: boolean; // 是否启用 HyDE
- // 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,
- scoreThreshold: 0.5,
- similarityThreshold: 0.7, // 默认相似度阈值
- enableFullTextSearch: false, // 默认关闭全文检索
- enableQueryExpansion: false,
- enableHyDE: false,
- language: 'ja',
- };
- export const API_BASE_URL = '/api'
|