Class: Phronomy::VectorStore::Base
- Inherits:
-
Object
- Object
- Phronomy::VectorStore::Base
- Includes:
- AsyncBackend
- Defined in:
- lib/phronomy/vector_store/base.rb
Overview
Public extension SPI for vector stores.
Backends implement the synchronous add/search/remove/clear/size contract. Phronomy supplies async convenience methods through AsyncBackend; blocking backend work is offloaded through the framework-owned bounded OffloadPool.
Direct Known Subclasses
Instance Method Summary collapse
-
#add(id:, embedding:, metadata: {}, cancellation_token: nil) ⇒ Object
Add a document with its vector embedding.
-
#clear ⇒ Object
Remove all documents.
-
#remove(id:) ⇒ Object
Remove a single document by id.
-
#search(query_embedding:, k: 5, cancellation_token: nil) ⇒ Array<Hash>
Return the k most similar documents to the query embedding.
-
#size ⇒ Integer
Return the number of documents stored.
Methods included from AsyncBackend
#add_async, #clear_async, #remove_async, #search_async
Instance Method Details
#add(id:, embedding:, metadata: {}, cancellation_token: nil) ⇒ Object
Add a document with its vector embedding.
22 23 24 25 |
# File 'lib/phronomy/vector_store/base.rb', line 22 def add(id:, embedding:, metadata: {}, cancellation_token: nil) cancellation_token&.raise_if_cancelled! raise NotImplementedError, "#{self.class}#add is not implemented" end |
#clear ⇒ Object
Remove all documents.
49 50 51 |
# File 'lib/phronomy/vector_store/base.rb', line 49 def clear raise NotImplementedError, "#{self.class}#clear is not implemented" end |
#remove(id:) ⇒ Object
Remove a single document by id.
43 44 45 |
# File 'lib/phronomy/vector_store/base.rb', line 43 def remove(id:) raise NotImplementedError, "#{self.class}#remove is not implemented" end |
#search(query_embedding:, k: 5, cancellation_token: nil) ⇒ Array<Hash>
Return the k most similar documents to the query embedding.
34 35 36 37 |
# File 'lib/phronomy/vector_store/base.rb', line 34 def search(query_embedding:, k: 5, cancellation_token: nil) cancellation_token&.raise_if_cancelled! raise NotImplementedError, "#{self.class}#search is not implemented" end |
#size ⇒ Integer
Return the number of documents stored.
57 58 59 |
# File 'lib/phronomy/vector_store/base.rb', line 57 def size raise NotImplementedError, "#{self.class}#size is not implemented" end |