Class: OpenAI::Resources::Embeddings

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Embeddings

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Embeddings.

Parameters:



42
43
44
# File 'lib/openai/resources/embeddings.rb', line 42

def initialize(client:)
  @client = client
end

Instance Method Details

#create(input: , model: , dimensions: nil, encoding_format: nil, user: nil, request_options: {}) ⇒ OpenAI::Models::CreateEmbeddingResponse

Some parameter documentations has been truncated, see Models::EmbeddingCreateParams for more details.

Creates an embedding vector representing the input text.

Parameters:

  • input (String, Array<String>, Array<Integer>, Array<Array<Integer>>)

    Input text to embed, encoded as a string or array of tokens. To embed multiple i

  • model (String, Symbol, OpenAI::Models::EmbeddingModel)

    ID of the model to use. You can use the [List models](platform.openai.co

  • dimensions (Integer)

    The number of dimensions the resulting output embeddings should have. Only suppo

  • encoding_format (Symbol, OpenAI::Models::EmbeddingCreateParams::EncodingFormat)

    The format to return the embeddings in. Can be either ‘float` or [`base64`](http

  • user (String)

    A unique identifier representing your end-user, which can help OpenAI to monitor

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
# File 'lib/openai/resources/embeddings.rb', line 28

def create(params)
  parsed, options = OpenAI::EmbeddingCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "embeddings",
    body: parsed,
    model: OpenAI::CreateEmbeddingResponse,
    options: options
  )
end