Module: Chromable::InstanceMethods
- Defined in:
- lib/chromable.rb
Overview
Methods to be added to the model instances.
Class Method Summary collapse
Instance Method Summary collapse
- #chroma_destroy_embedding ⇒ Object
- #chroma_embedding ⇒ Object
- #chroma_neighbors(results: 10, where: {}, where_document: {}) ⇒ Object
- #chroma_upsert_embedding ⇒ Object
Class Method Details
.included(base) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/chromable.rb', line 66 def self.included(base) base.instance_eval do # rubocop:disable Style/Alias alias_method :embedding, :chroma_embedding unless method_defined? :embedding alias_method :upsert_embedding, :chroma_upsert_embedding unless method_defined? :upsert_embedding alias_method :destroy_embedding, :chroma_destroy_embedding unless method_defined? :destroy_embedding alias_method :neighbors, :chroma_neighbors unless method_defined? :neighbors # rubocop:enable Style/Alias end end |
Instance Method Details
#chroma_destroy_embedding ⇒ Object
85 86 87 |
# File 'lib/chromable.rb', line 85 def self.class.chroma_collection.delete(ids: [id]) end |
#chroma_embedding ⇒ Object
77 78 79 |
# File 'lib/chromable.rb', line 77 def self.class.chroma_collection.get(ids: [id])[0] end |
#chroma_neighbors(results: 10, where: {}, where_document: {}) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/chromable.rb', line 89 def chroma_neighbors(results: 10, where: {}, where_document: {}) collection = self.class.chroma_collection = collection.get(ids: [id], include: [:embeddings])[0]. self.class.find(collection.query( query_embeddings: [], results: results, where: where, where_document: where_document ).map(&:id)) end |
#chroma_upsert_embedding ⇒ Object
81 82 83 |
# File 'lib/chromable.rb', line 81 def self.class.chroma_collection.upsert() end |