Sha256: bc16bd94e4d8fd2b2748e6c6af4801339ee4c81ca99d4ba4b3902a4a75f15326

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "active_support/core_ext/module/delegation"

module Roseflow
  module OpenAI
    class ModelRepository
      attr_reader :models

      delegate :each, :all, to: :models
      
      def initialize(provider)
        @provider = provider
        @models = provider.client.models
      end

      # Finds a model by name.
      #
      # @param name [String] Name of the model
      def find(name)
        @models.select{ |model| model.name == name }.first
      end

      # Returns all models that are chattable.
      def chattable
        @models.select(&:chattable?)
      end

      # Returns all models that are completionable.
      def completionable
        @models.select(&:completionable?)
      end

      # Returns all models that are support edits.
      def editable
        @models.select(&:editable?)
      end

      # Returns all models that are support embeddings.
      def embeddable
        @models.select(&:embeddable?)
      end
    end # ModelRepository
  end # OpenAI
end # Roseflow

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roseflow-openai-0.2.0 lib/roseflow/openai/model_repository.rb
roseflow-openai-0.1.0 lib/roseflow/openai/model_repository.rb