feat: add semantic/RAG vault indexing with automatic background sync
- Add VaultVectorStore backed by ChromaDB for vector-based vault search - Integrate existing ContentVectorizer/IndexingPipeline for embeddings - Update VaultIndexer to prefer semantic search with keyword fallback - Background indexing on plugin load + incremental sync via vault events - Add vault index settings, commands, and UI controls - Add tests for VaultVectorStore - Update README with RAG setup instructions
This commit is contained in:
+9
-2
@@ -1,6 +1,7 @@
|
||||
import { ItemView, Notice, WorkspaceLeaf } from 'obsidian';
|
||||
import { OllamaClient } from './ollama-client';
|
||||
import { VaultIndexer } from './vault-indexer';
|
||||
import { VaultVectorStore } from './vault-vector-store';
|
||||
import { ToolExecutor } from './tool-executor';
|
||||
import { PluginSettings, OllamaMessage, OllamaTool, OllamaToolCall, ChatMessage } from './types';
|
||||
import { ConversationStateManager } from './conversation-state';
|
||||
@@ -22,7 +23,7 @@ export class ChatView extends ItemView {
|
||||
return this.newChatButtonClickHandler;
|
||||
}
|
||||
|
||||
constructor(leaf: WorkspaceLeaf, settings: PluginSettings) {
|
||||
constructor(leaf: WorkspaceLeaf, settings: PluginSettings, vectorStore?: VaultVectorStore) {
|
||||
super(leaf);
|
||||
this.messages = [];
|
||||
this.lastMessageEl = null;
|
||||
@@ -44,7 +45,7 @@ export class ChatView extends ItemView {
|
||||
undefined,
|
||||
settings.cacheConfig
|
||||
);
|
||||
this.vaultIndexer = new VaultIndexer(this.app.vault);
|
||||
this.vaultIndexer = new VaultIndexer(this.app.vault, undefined, vectorStore);
|
||||
this.toolExecutor = new ToolExecutor(this.app.vault, this.app);
|
||||
this.conversationStateManager = new ConversationStateManager();
|
||||
}
|
||||
@@ -64,6 +65,11 @@ export class ChatView extends ItemView {
|
||||
});
|
||||
}
|
||||
|
||||
setVectorStore(vectorStore: VaultVectorStore | undefined) {
|
||||
this.vectorStore = vectorStore;
|
||||
this.vaultIndexer.setVectorStore(vectorStore);
|
||||
}
|
||||
|
||||
async clearCache(): Promise<void> {
|
||||
await this.ollamaClient.clearCache();
|
||||
}
|
||||
@@ -567,6 +573,7 @@ export class ChatView extends ItemView {
|
||||
private vaultIndexer: VaultIndexer;
|
||||
private toolExecutor: ToolExecutor;
|
||||
private conversationStateManager: ConversationStateManager;
|
||||
private vectorStore?: VaultVectorStore;
|
||||
}
|
||||
|
||||
const MAX_TOOL_CALLS = 5;
|
||||
|
||||
Reference in New Issue
Block a user