Class: Phronomy::VectorStore::Base
- Inherits:
-
Object
- Object
- Phronomy::VectorStore::Base
- Defined in:
- lib/phronomy/vector_store/base.rb
Overview
Abstract interface for vector stores.
Implementations manage a collection of (embedding, metadata) pairs and support similarity search.
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.
Instance Method Details
#add(id:, embedding:, metadata: {}, cancellation_token: nil) ⇒ Object
Add a document with its vector embedding.
17 18 19 20 |
# File 'lib/phronomy/vector_store/base.rb', line 17 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.
43 44 45 |
# File 'lib/phronomy/vector_store/base.rb', line 43 def clear raise NotImplementedError, "#{self.class}#clear is not implemented" end |
#remove(id:) ⇒ Object
Remove a single document by id.
38 39 40 |
# File 'lib/phronomy/vector_store/base.rb', line 38 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.
29 30 31 32 |
# File 'lib/phronomy/vector_store/base.rb', line 29 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.
51 52 53 |
# File 'lib/phronomy/vector_store/base.rb', line 51 def size raise NotImplementedError, "#{self.class}#size is not implemented" end |