Class: Aoororachain::VectorStores::Retriever

Inherits:
Object
  • Object
show all
Defined in:
lib/aoororachain/vector_stores/retriever.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vector_store, search_type: :similarity, results: 3) ⇒ Retriever

Returns a new instance of Retriever.



8
9
10
11
12
# File 'lib/aoororachain/vector_stores/retriever.rb', line 8

def initialize(vector_store, search_type: :similarity, results: 3)
  @vector_store = vector_store
  @search_type = search_type
  @results = results
end

Instance Attribute Details

#resultsObject

Returns the value of attribute results.



6
7
8
# File 'lib/aoororachain/vector_stores/retriever.rb', line 6

def results
  @results
end

#search_typeObject

Returns the value of attribute search_type.



6
7
8
# File 'lib/aoororachain/vector_stores/retriever.rb', line 6

def search_type
  @search_type
end

Instance Method Details

#search(query, **options) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/aoororachain/vector_stores/retriever.rb', line 14

def search(query, **options)
  results = options.delete(:results) || @results
  filter = options.delete(:filter) || {}

  if @search_type == :similarity
    @vector_store.similarity_search(query, results:, filter:)
  end
end