Class: Roseflow::VectorStores::Type::Vector
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- Roseflow::VectorStores::Type::Vector
- Defined in:
- lib/roseflow/vector_stores/type/vector.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cast(value) ⇒ Object
- #deserialize(value) ⇒ Object
-
#initialize(dimensions:, model:, attribute_name:) ⇒ Vector
constructor
A new instance of Vector.
- #serialize(value) ⇒ Object
Constructor Details
#initialize(dimensions:, model:, attribute_name:) ⇒ Vector
Returns a new instance of Vector.
9 10 11 12 13 14 |
# File 'lib/roseflow/vector_stores/type/vector.rb', line 9 def initialize(dimensions:, model:, attribute_name:) super() @dimensions = dimensions @model = model @attribute_name = attribute_name end |
Class Method Details
.cast(value, dimensions:) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/roseflow/vector_stores/type/vector.rb', line 16 def self.cast(value, dimensions:) value = value.to_a.map(&:to_f) raise Error, "Values must be finite" unless value.all?(&:finite?) value end |
Instance Method Details
#cast(value) ⇒ Object
24 25 26 |
# File 'lib/roseflow/vector_stores/type/vector.rb', line 24 def cast(value) self.class.cast(value, dimensions: @dimensions) unless value.nil? end |
#deserialize(value) ⇒ Object
32 33 34 |
# File 'lib/roseflow/vector_stores/type/vector.rb', line 32 def deserialize(value) raise NotImplementedError end |
#serialize(value) ⇒ Object
28 29 30 |
# File 'lib/roseflow/vector_stores/type/vector.rb', line 28 def serialize(value) raise NotImplementedError end |