Sha256: f4cc4624ec34be20c93967b77063c1505c3db290649c8bf41cb4d59ba2870c08
Contents?: true
Size: 843 Bytes
Versions: 1
Compression:
Stored size: 843 Bytes
Contents
# frozen_string_literal: true require "active_model/type" module Roseflow module VectorStores module Type class Vector < ActiveModel::Type::Value def initialize(dimensions:, model:, attribute_name:) super() @dimensions = dimensions @model = model @attribute_name = attribute_name end def self.cast(value, dimensions:) value = value.to_a.map(&:to_f) raise Error, "Values must be finite" unless value.all?(&:finite?) value end def cast(value) self.class.cast(value, dimensions: @dimensions) unless value.nil? end def serialize(value) raise NotImplementedError end def deserialize(value) raise NotImplementedError end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roseflow-0.1.0 | lib/roseflow/vector_stores/type/vector.rb |