Class: Roseflow::Pinecone::Vector::Upsert

Inherits:
PineconeObject
  • Object
show all
Includes:
Roseflow::Pinecone::Vectors::Common
Defined in:
lib/roseflow/pinecone/vectors/upsert.rb

Defined Under Namespace

Classes: UpsertContract

Class Method Summary collapse

Methods included from Roseflow::Pinecone::Vectors::Common

extended, included, #to_json

Class Method Details

.from(data) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
# File 'lib/roseflow/pinecone/vectors/upsert.rb', line 32

def self.from(data)
  raise ArgumentError, "Data must be a valid upsert hash" unless data.is_a?(Hash) && data.keys.include?(:vectors)
  new(
    vectors: data[:vectors].map { |vector| VectorObject.new(id: vector[:id], values: vector[:values]) },
    namespace: data[:namespace]
  )
end