Class: OmniAI::Embed

Inherits:
Object
  • Object
show all
Defined in:
lib/omniai/embed.rb,
lib/omniai/embed/usage.rb,
lib/omniai/embed/response.rb

Overview

An abstract class that provides a consistent interface for processing embedding requests.

Usage:

class OmniAI::OpenAI::Embed < OmniAI::Embed
  module Model
    SMALL = "text-embedding-3-small"
    LARGE = "text-embedding-3-large"
    ADA = "text-embedding-3-002"
  end

  protected

  # @return [Hash]
  def payload
    { ... }
  end

  # @return [String]
  def path
    "..."
  end
end

client.embed(input, model: "...")

Defined Under Namespace

Classes: Response, Usage

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, client:, model:) ⇒ Response

Parameters:

  • input (String)

    required

  • client (Client)

    the client

  • model (String)

    required



39
40
41
42
43
# File 'lib/omniai/embed.rb', line 39

def initialize(input, client:, model:)
  @input = input
  @client = client
  @model = model
end

Class Method Details

.process!Object



30
31
32
# File 'lib/omniai/embed.rb', line 30

def self.process!(...)
  new(...).process!
end

Instance Method Details

#process!Response

Returns:

Raises:



47
48
49
50
51
52
# File 'lib/omniai/embed.rb', line 47

def process!
  response = request!
  raise HTTPError, response.flush unless response.status.ok?

  parse!(response:)
end