View Source OpenaiEx.Embedding (openai_ex v0.5.4)

This module provides an implementation of the OpenAI embeddings API. The API reference can be found at https://platform.openai.com/docs/api-reference/embeddings.

API Fields

The following fields can be used as parameters when creating a new embedding:

  • :input
  • :model
  • :encoding_format
  • :user

Summary

Functions

Calls the embedding endpoint.

Creates a new embedding request with the given arguments.

Functions

Link to this function

create(openai, embedding)

View Source

Calls the embedding endpoint.

Arguments

  • openai: The OpenAI configuration to use.
  • embedding: The embedding request to send.

Returns

A map containing the fields of the embedding response.

See https://platform.openai.com/docs/api-reference/embeddings/create for more information.

Creates a new embedding request with the given arguments.

Arguments

  • args: A list of key-value pairs, or a map, representing the fields of the embedding request.

Returns

A map containing the fields of the embedding request.

The :model and :input fields are required.

Example usage:

iex> _request = OpenaiEx.Embedding.new(model: "davinci", input: "This is a test")
%{input: "This is a test", model: "davinci"}

iex> _request = OpenaiEx.Embedding.new(%{model: "davinci", input: "This is a test"})
%{input: "This is a test", model: "davinci"}