Class: Roseflow::Pinecone::VectorStore
- Inherits:
-
VectorStores::Base
- Object
- VectorStores::Base
- Roseflow::Pinecone::VectorStore
- Defined in:
- lib/roseflow/pinecone/vector_store.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #build_vector(name, content) ⇒ Object
- #create_vector(name, vector, **options) ⇒ Object
- #delete_vector(name, id) ⇒ Object
- #find(name, ids, **options) ⇒ Object
- #index(name) ⇒ Object
-
#initialize ⇒ VectorStore
constructor
A new instance of VectorStore.
- #query(name, query) ⇒ Object (also: #where)
- #update_vector(name, vector) ⇒ Object
Constructor Details
#initialize ⇒ VectorStore
Returns a new instance of VectorStore.
13 14 15 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 13 def initialize @client = Roseflow::Pinecone::Client.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 11 def client @client end |
Instance Method Details
#build_vector(name, content) ⇒ Object
21 22 23 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 21 def build_vector(name, content) Vector.build(id: name, values: content) end |
#create_vector(name, vector, **options) ⇒ Object
25 26 27 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 25 def create_vector(name, vector, **) index(name).upsert(.merge(vectors: [vector])) end |
#delete_vector(name, id) ⇒ Object
29 30 31 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 29 def delete_vector(name, id) index(name).delete(ids: [id]) end |
#find(name, ids, **options) ⇒ Object
43 44 45 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 43 def find(name, ids, **) index(name).fetch(.merge(ids: ids)).vectors.first end |
#index(name) ⇒ Object
17 18 19 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 17 def index(name) client.index(name) end |
#query(name, query) ⇒ Object Also known as: where
37 38 39 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 37 def query(name, query) index(name).query(query).vectors end |
#update_vector(name, vector) ⇒ Object
33 34 35 |
# File 'lib/roseflow/pinecone/vector_store.rb', line 33 def update_vector(name, vector) index(name).update(vector) end |