Add semantic cache support using ChromaDB

This commit is contained in:
2026-05-07 20:53:28 +02:00
parent f3a10a4b01
commit 179a58b95b
10 changed files with 1343 additions and 257 deletions
+15 -5
View File
@@ -54,14 +54,24 @@ export class ChatView extends ItemView {
constructor(leaf: WorkspaceLeaf, settings: PluginSettings) {
super(leaf);
this.settings = settings;
this.ollamaClient = new OllamaClient(settings.ollamaUrl, settings.model);
this.ollamaClient = new OllamaClient(
settings.ollamaUrl,
settings.model,
undefined,
settings.cacheConfig
);
this.vaultIndexer = new VaultIndexer(this.app.vault);
this.toolExecutor = new ToolExecutor(this.app.vault, this.app);
}
public updateSettings(newSettings: PluginSettings): void {
this.settings = newSettings;
this.ollamaClient = new OllamaClient(newSettings.ollamaUrl, newSettings.model);
this.ollamaClient = new OllamaClient(
newSettings.ollamaUrl,
newSettings.model,
undefined,
newSettings.cacheConfig
);
}
getViewType(): string {
@@ -72,18 +82,18 @@ export class ChatView extends ItemView {
return 'Ollama Chat';
}
onOpen(): Promise<void> {
async onOpen(): Promise<void> {
await this.ollamaClient.initializeCache();
this.render();
this.removeEventListeners(); // Clean up any existing listeners before reattaching
this.setupEventListeners();
return Promise.resolve();
}
public onSettingsChange(newSettings: PluginSettings): void {
this.updateSettings(newSettings);
}
onClose(): Promise<void> {
async onClose(): Promise<void> {
this.ollamaClient.cancelStream();
this.removeEventListeners();
this.cleanupStreamingResources();