feat(llm): also add functions to clear/unregister embedding providers

This commit is contained in:
perf3ct
2025-06-05 18:59:32 +00:00
parent 49e123f399
commit c1b10d70b8
3 changed files with 43 additions and 12 deletions

View File

@@ -845,17 +845,21 @@ export class IndexService {
try {
log.info("Starting embedding generation system");
// Re-initialize if needed
if (!this.initialized) {
await this.initialize();
}
const aiEnabled = options.getOptionOrNull('aiEnabled') === "true";
if (!aiEnabled) {
log.error("Cannot start embedding generation - AI features are disabled");
throw new Error("AI features must be enabled first");
}
// Re-initialize providers first in case they weren't available when server started
log.info("Re-initializing embedding providers");
await providerManager.initializeDefaultProviders();
// Re-initialize if needed
if (!this.initialized) {
await this.initialize();
}
// Check if this instance should process embeddings
const embeddingLocation = await options.getOption('embeddingGenerationLocation') || 'client';
const isSyncServer = await this.isSyncServerForEmbeddings();
@@ -902,6 +906,9 @@ export class IndexService {
// Stop the background processing from embeddings/events.ts
vectorStore.stopEmbeddingBackgroundProcessing();
// Clear all embedding providers to clean up resources
providerManager.clearAllEmbeddingProviders();
// Mark as not indexing
this.indexingInProgress = false;
this.indexRebuildInProgress = false;