types.ts 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. export interface IndexingConfig {
  2. chunkSize: number;
  3. chunkOverlap: number;
  4. embeddingModelId: string;
  5. mode?: 'fast' | 'precise'; // Processing mode: fast/precise
  6. groupIds?: string[]; // Groups to associate with the file upon upload
  7. }
  8. export interface VisionAnalysisResult {
  9. text: string; // Extracted text content
  10. images: ImageDescription[]; // Image descriptions
  11. layout: string; // Layout type
  12. confidence: number;
  13. pageIndex?: number; // Page number
  14. }
  15. export interface ImageDescription {
  16. type: string; // Image type (graph/diagram/flowchart etc.)
  17. description: string; // Detailed description
  18. position?: number; // Position within the page
  19. }
  20. export interface PipelineResult {
  21. success: boolean;
  22. fileId: string;
  23. fileName: string;
  24. totalPages: number;
  25. processedPages: number;
  26. failedPages: number;
  27. results: VisionAnalysisResult[];
  28. cost: number; // Cost (USD)
  29. duration: number; // Duration (seconds)
  30. mode: 'precise';
  31. }
  32. export interface ModeRecommendation {
  33. recommendedMode: 'precise' | 'fast';
  34. reason: string;
  35. estimatedCost?: number; // Estimated cost (USD)
  36. estimatedTime?: number; // Estimated time (seconds)
  37. warnings?: string[];
  38. }
  39. // Type definitions for knowledge base extensions
  40. export interface KnowledgeGroup {
  41. id: string;
  42. name: string;
  43. description?: string;
  44. color: string;
  45. fileCount: number;
  46. parentId?: string | null;
  47. children?: KnowledgeGroup[];
  48. createdAt: string;
  49. updatedAt?: string;
  50. }
  51. export interface CreateGroupData {
  52. name: string;
  53. description?: string;
  54. color?: string;
  55. parentId?: string | null;
  56. }
  57. export interface UpdateGroupData {
  58. name?: string;
  59. description?: string;
  60. color?: string;
  61. parentId?: string | null;
  62. }
  63. export interface KnowledgeFile {
  64. id: string;
  65. name: string;
  66. originalName: string;
  67. size: number;
  68. type: string;
  69. status: 'pending' | 'indexing' | 'extracted' | 'vectorized' | 'failed' | 'ready' | 'error';
  70. groups?: KnowledgeGroup[];
  71. createdAt: string;
  72. updatedAt: string;
  73. }
  74. export interface SearchHistoryItem {
  75. id: string;
  76. title: string;
  77. selectedGroups: string[] | null;
  78. messageCount: number;
  79. lastMessageAt: string;
  80. createdAt: string;
  81. }
  82. export interface SearchHistoryDetail {
  83. id: string;
  84. title: string;
  85. selectedGroups: string[] | null;
  86. messages: Array<{
  87. id: string;
  88. role: 'user' | 'assistant';
  89. content: string;
  90. sources?: Array<{
  91. fileName: string;
  92. content: string;
  93. score: number;
  94. chunkIndex: number;
  95. }>;
  96. createdAt: string;
  97. }>;
  98. }
  99. export interface PDFStatus {
  100. status: 'pending' | 'converting' | 'ready' | 'failed';
  101. pdfPath?: string;
  102. error?: string;
  103. }
  104. export interface NoteCategory {
  105. id: string
  106. name: string
  107. parentId?: string
  108. level: number
  109. userId: string
  110. tenantId: string
  111. createdAt: string
  112. updatedAt: string
  113. }
  114. export interface Note {
  115. id: string;
  116. title: string;
  117. content: string;
  118. userId: string;
  119. tenantId?: string;
  120. groupId?: string;
  121. categoryId?: string;
  122. sharingStatus: 'PRIVATE' | 'TENANT' | 'GLOBAL_PENDING' | 'GLOBAL_APPROVED';
  123. createdAt: string;
  124. updatedAt: string;
  125. user?: {
  126. id: string;
  127. username: string;
  128. };
  129. }
  130. export interface RawFile {
  131. name: string;
  132. type: string;
  133. size: number;
  134. content: string;
  135. preview?: string;
  136. file: File; // Keep original file for upload
  137. isNote?: boolean;
  138. textContent?: string;
  139. }
  140. export enum Role {
  141. USER = 'user',
  142. MODEL = 'model',
  143. }
  144. export interface Message {
  145. id: string;
  146. role: Role;
  147. text: string;
  148. timestamp: number;
  149. isError?: boolean;
  150. sources?: ChatSource[];
  151. }
  152. export interface ChatSource {
  153. fileName: string;
  154. title?: string;
  155. content: string;
  156. score: number;
  157. chunkIndex: number;
  158. fileId?: string;
  159. }
  160. export interface ChatState {
  161. messages: Message[];
  162. isLoading: boolean;
  163. }
  164. export type Language = 'ja' | 'en' | 'zh';
  165. export enum ModelType {
  166. // Changed from type to enum
  167. LLM = "llm",
  168. EMBEDDING = "embedding",
  169. RERANK = "rerank",
  170. VISION = "vision",
  171. }
  172. // 1. Model Definition (The "Provider" setup)
  173. export interface ModelConfig {
  174. id: string;
  175. name: string; // Display name, e.g. "My DeepSeek"
  176. modelId: string; // The actual string ID sent to API, e.g., "gpt-4o"
  177. baseUrl?: string; // Base URL for OpenAI compatible API
  178. apiKey?: string; // API key for the service
  179. type: ModelType;
  180. dimensions?: number; // Vector dimensions of the embedding model
  181. supportsVision?: boolean; // Whether it supports vision capabilities
  182. // ==================== Additional Fields ====================
  183. /**
  184. * Model's input token limit
  185. * e.g., OpenAI=8191, Gemini=2048
  186. */
  187. maxInputTokens?: number;
  188. /**
  189. * Batch processing limit (maximum number of inputs per request)
  190. * e.g., OpenAI=2048, Gemini=100
  191. */
  192. maxBatchSize?: number;
  193. /**
  194. * Whether it is a vector model (for identification in system settings)
  195. */
  196. isVectorModel?: boolean;
  197. /**
  198. * Model provider name (for display)
  199. * e.g., "OpenAI", "Google Gemini", "Custom"
  200. */
  201. providerName?: string;
  202. /**
  203. * Whether it is enabled
  204. */
  205. isEnabled?: boolean;
  206. /**
  207. * Whether to use this model as the default
  208. */
  209. isDefault?: boolean;
  210. }
  211. // 2. Application Logic Settings (The "App" setup)
  212. export interface AppSettings {
  213. // References to ModelConfig IDs
  214. selectedLLMId: string;
  215. selectedEmbeddingId: string; // Default for new uploads, and used for query encoding
  216. selectedRerankId: string;
  217. // Model Hyperparameters
  218. temperature: number;
  219. maxTokens: number;
  220. // Retrieval
  221. enableRerank: boolean;
  222. topK: number;
  223. similarityThreshold: number; // Similarity threshold for vector search
  224. rerankSimilarityThreshold: number; // Similarity threshold for reranking
  225. enableFullTextSearch: boolean; // Whether to enable full-text search
  226. hybridVectorWeight: number; // Vector weight for hybrid search
  227. // Search Enhancement
  228. enableQueryExpansion: boolean;
  229. enableHyDE: boolean;
  230. chunkSize?: number;
  231. chunkOverlap?: number;
  232. // Language
  233. language?: string;
  234. // Coach
  235. coachKbId?: string;
  236. }
  237. // Default Models (Frontend specific)
  238. export const DEFAULT_MODELS: ModelConfig[] = [];
  239. export const DEFAULT_SETTINGS: AppSettings = {
  240. selectedLLMId: '',
  241. selectedEmbeddingId: '',
  242. selectedRerankId: '',
  243. temperature: 0.3,
  244. maxTokens: 8192,
  245. enableRerank: false,
  246. topK: 4,
  247. similarityThreshold: 0.3, // Default similarity threshold for vector search
  248. rerankSimilarityThreshold: 0.5, // Default similarity threshold for reranking
  249. enableFullTextSearch: false, // Turn off full-text search by default
  250. hybridVectorWeight: 0.7, // Vector weight for hybrid search
  251. enableQueryExpansion: false,
  252. enableHyDE: false,
  253. chunkSize: 1000,
  254. chunkOverlap: 100,
  255. language: 'ja',
  256. };
  257. export const API_BASE_URL = '/api'
  258. // Assessment Types
  259. export interface AssessmentSession {
  260. id: string;
  261. status: 'STARTED' | 'COMPLETED' | 'FAILED';
  262. masteryLevel?: string;
  263. report?: string;
  264. createdAt: string;
  265. updatedAt: string;
  266. }
  267. export interface AssessmentQuestion {
  268. id: string;
  269. content: string;
  270. keyPoints?: string[];
  271. isAnswered: boolean;
  272. score?: number;
  273. feedback?: string;
  274. }
  275. export interface AssessmentState {
  276. session: AssessmentSession;
  277. questions: AssessmentQuestion[];
  278. currentQuestion?: AssessmentQuestion;
  279. isFinished: boolean;
  280. messages: Array<{
  281. role: 'user' | 'assistant';
  282. content: string;
  283. timestamp: number;
  284. }>;
  285. }