View Source OpenaiEx.Embeddings (openai_ex v0.6.2)

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.

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.Embeddings.new(model: "text-embedding-ada-002", input: "This is a test")
%{input: "This is a test", model: "text-embedding-ada-002"}

iex> _request = OpenaiEx.Embeddings.new(%{model: "text-embedding-ada-002", input: "This is a test"})
%{input: "This is a test", model: "text-embedding-ada-002"}