Sha256: e984768c6f730cf4f8f41796088f94be524ea44f4bc417acb22a8410341001fe

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

module Roseflow
  module Embeddings
    EmbeddingModelNotSpecifiedError = Class.new(StandardError)
    
    class Embedding
      attr_reader :length, :vector
      attr_writer :input

      def initialize(**kwargs)
        @length = kwargs.fetch(:length, 1024)
        @input = kwargs.fetch(:input, nil)
        @model = kwargs.fetch(:model, nil)
        @vector = kwargs.fetch(:vector, nil)
      end

      def call
        raise ArgumentError, "An input must be provided" unless @input
        raise EmbeddingModelNotSpecifiedError, "An embedding model must be specified" unless @model
        response = @model.provider.create_embedding(model: @model, input: @input)
        response.embedding
      end
    end # Embedding
  end # Embeddings
end # Roseflow

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roseflow-0.1.0 lib/roseflow/embeddings/embedding.rb