Class: GroqRuby::Resources::Embeddings

Inherits:
Base
  • Object
show all
Defined in:
lib/groq_ruby/resources/embeddings.rb

Overview

‘client.embeddings.create(…)` — turns text into vectors.

Constant Summary collapse

PATH =
"/openai/v1/embeddings".freeze
SCHEMA =
Dry::Schema.define do
  required(:model).filled(:string)
  required(:input)
  optional(:encoding_format).filled(:string, included_in?: %w[float base64])
  optional(:user).maybe(:string)
end

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GroqRuby::Resources::Base

Instance Method Details

#create(**params) ⇒ GroqRuby::Models::CreateEmbeddingResponse

Parameters:

  • params (Hash)

    required: ‘:model`, `:input` (String or Array of Strings). Optional: `:encoding_format` (`“float”` | `“base64”`), `:user`.

Returns:

Raises:



21
22
23
24
25
# File 'lib/groq_ruby/resources/embeddings.rb', line 21

def create(**params)
  body = validate!(SCHEMA, params)
  payload = perform(Request.new(method: :post, path: PATH, body: body))
  GroqRuby::Models::CreateEmbeddingResponse.from_hash(payload)
end