Module: KairosMcp::VectorSearch
- Defined in:
- lib/kairos_mcp/vector_search/base.rb,
lib/kairos_mcp/vector_search/provider.rb,
lib/kairos_mcp/vector_search/fallback_search.rb,
lib/kairos_mcp/vector_search/semantic_search.rb
Defined Under Namespace
Classes: Base, FallbackSearch, SemanticSearch
Class Method Summary collapse
-
.available? ⇒ Boolean
Check if semantic search gems are available.
-
.check_gems_available ⇒ Boolean
Check gems without caching (useful for testing).
-
.create(index_path: nil, dimension: 384, model: nil, force_fallback: false) ⇒ Base
Create a vector search instance.
-
.reset_availability! ⇒ Object
Reset the availability cache (for testing).
-
.status ⇒ Hash
Get status information about vector search.
Class Method Details
.available? ⇒ Boolean
Check if semantic search gems are available
23 24 25 26 27 |
# File 'lib/kairos_mcp/vector_search/provider.rb', line 23 def available? return @available if defined?(@available) @available = check_gems_available end |
.check_gems_available ⇒ Boolean
Check gems without caching (useful for testing)
32 33 34 35 36 37 38 |
# File 'lib/kairos_mcp/vector_search/provider.rb', line 32 def check_gems_available require 'hnswlib' require 'informers' true rescue LoadError false end |
.create(index_path: nil, dimension: 384, model: nil, force_fallback: false) ⇒ Base
Create a vector search instance
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/kairos_mcp/vector_search/provider.rb', line 52 def create(index_path: nil, dimension: 384, model: nil, force_fallback: false) if !force_fallback && available? require_relative 'semantic_search' SemanticSearch.new( index_path: index_path || default_index_path, dimension: dimension, model: model || SemanticSearch::DEFAULT_MODEL ) else require_relative 'fallback_search' FallbackSearch.new end end |
.reset_availability! ⇒ Object
Reset the availability cache (for testing)
41 42 43 |
# File 'lib/kairos_mcp/vector_search/provider.rb', line 41 def reset_availability! remove_instance_variable(:@available) if defined?(@available) end |
.status ⇒ Hash
Get status information about vector search
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kairos_mcp/vector_search/provider.rb', line 69 def status { semantic_available: available?, gems: { hnswlib: gem_version('hnswlib'), informers: gem_version('informers') }, default_model: available? ? 'sentence-transformers/all-MiniLM-L6-v2' : nil, default_dimension: 384 } end |