Class: Roseflow::Pinecone::VectorStore

Inherits:
VectorStores::Base
  • Object
show all
Defined in:
lib/roseflow/pinecone/vector_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVectorStore

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

#clientObject (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, **options)
  index(name).upsert(options.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, **options)
  index(name).fetch(options.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