Module: OllamaChat::DocumentCache
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/document_cache.rb
Overview
Module for handling document caching and retrieval using embedding similarity.
This module provides methods to configure cache backends and manage document storage with semantic search capabilities. It integrates with Documentrix’s document management system to enable efficient storage, retrieval, and similarity-based searching of documents using vector embeddings.
Instance Method Summary collapse
-
#configure_cache ⇒ Class
Configures and returns the appropriate cache class based on command-line options.
-
#document_cache_class ⇒ Class
Retrieves the cache class specified in the configuration.
Instance Method Details
#configure_cache ⇒ Class
Configures and returns the appropriate cache class based on command-line options.
Determines which cache implementation to use based on command-line flags:
-
If the
-Mflag is set, uses Documentrix::Documents::MemoryCache -
Otherwise, resolves and returns the cache class specified in configuration
Falls back to Documentrix::Documents::MemoryCache if configuration resolution fails.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ollama_chat/document_cache.rb', line 37 def configure_cache if @opts[?M] Documentrix::Documents::MemoryCache else document_cache_class end rescue => e STDERR.puts "Caught #{e.class}: #{e} => Falling back to MemoryCache." Documentrix::Documents::MemoryCache end |
#document_cache_class ⇒ Class
Retrieves the cache class specified in the configuration.
This method resolves the cache class name from the application’s configuration to dynamically load the appropriate cache implementation.
18 19 20 |
# File 'lib/ollama_chat/document_cache.rb', line 18 def document_cache_class Object.const_get(config.cache) end |