mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	initialize embeddings if option is enabled
This commit is contained in:
		
							
								
								
									
										26
									
								
								src/services/llm/embeddings/init.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/services/llm/embeddings/init.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | import log from "../../log.js"; | ||||||
|  | import options from "../../options.js"; | ||||||
|  | import vectorStore from "./vector_store.js"; | ||||||
|  | import providerManager from "./providers.js"; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Initialize the embedding system | ||||||
|  |  */ | ||||||
|  | export async function initializeEmbeddings() { | ||||||
|  |     try { | ||||||
|  |         log.info("Initializing embedding system..."); | ||||||
|  |  | ||||||
|  |         // Initialize default embedding providers | ||||||
|  |         await providerManager.initializeDefaultProviders(); | ||||||
|  |  | ||||||
|  |         // Start the embedding system if AI is enabled | ||||||
|  |         if (await options.getOptionBool('aiEnabled')) { | ||||||
|  |             await vectorStore.initEmbeddings(); | ||||||
|  |             log.info("Embedding system initialized successfully."); | ||||||
|  |         } else { | ||||||
|  |             log.info("Embedding system disabled (AI features are turned off)."); | ||||||
|  |         } | ||||||
|  |     } catch (error: any) { | ||||||
|  |         log.error(`Error initializing embedding system: ${error.message || error}`); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -47,20 +47,26 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi | |||||||
|     encryptedDataKey: string; |     encryptedDataKey: string; | ||||||
|  |  | ||||||
|     // AI/LLM integration options |     // AI/LLM integration options | ||||||
|     aiEnabled: string; |     aiEnabled: boolean; | ||||||
|     openaiApiKey: string; |     openaiApiKey: string; | ||||||
|     openaiDefaultModel: string; |     openaiDefaultModel: string; | ||||||
|     openaiBaseUrl: string; |     openaiBaseUrl: string; | ||||||
|     anthropicApiKey: string; |     anthropicApiKey: string; | ||||||
|     anthropicDefaultModel: string; |     anthropicDefaultModel: string; | ||||||
|     anthropicBaseUrl: string; |     anthropicBaseUrl: string; | ||||||
|     ollamaEnabled: string; |     ollamaEnabled: boolean; | ||||||
|     ollamaBaseUrl: string; |     ollamaBaseUrl: string; | ||||||
|     ollamaDefaultModel: string; |     ollamaDefaultModel: string; | ||||||
|     aiProviderPrecedence: string; |     aiProviderPrecedence: string; | ||||||
|     aiTemperature: string; |     aiTemperature: string; | ||||||
|     aiSystemPrompt: string; |     aiSystemPrompt: string; | ||||||
|  |  | ||||||
|  |     // Embedding-related options | ||||||
|  |     embeddingAutoUpdateEnabled: boolean; | ||||||
|  |     embeddingUpdateInterval: number; | ||||||
|  |     embeddingBatchSize: number; | ||||||
|  |     embeddingDefaultDimension: number; | ||||||
|  |  | ||||||
|     lastSyncedPull: number; |     lastSyncedPull: number; | ||||||
|     lastSyncedPush: number; |     lastSyncedPush: number; | ||||||
|     revisionSnapshotTimeInterval: number; |     revisionSnapshotTimeInterval: number; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user