View Source Train.Clients.OpenAI (train v0.0.1-dev)

Link to this section Summary

Functions

Accepts a prompt string and queries OpenAI's embedding API and return the list of embeddings/

Queries OpenAI chat completions with the given messages. Accepts gpt-4 or gpt-3.5-turbo.

Link to this section Types

@type message() :: %{role: String.t(), content: String.t()}

Link to this section Functions

Link to this function

embedding(prompt, open_ai_config)

View Source
@spec embedding(String.t(), Train.Clients.OpenAIConfig.t()) ::
  {:ok, [float()]} | {:error, String.t()}

Accepts a prompt string and queries OpenAI's embedding API and return the list of embeddings/

Link to this function

generate(atom, message, config)

View Source
@spec generate(:user, String.t(), Train.Clients.OpenAIConfig.t()) ::
  {:ok, [String.t()], String.t()} | {:error, [String.t()], String.t()}
@spec generate(:messages, [message()], Train.Clients.OpenAIConfig.t()) ::
  {:ok, [String.t()], String.t()} | {:error, [String.t()], String.t()}

Queries OpenAI chat completions with the given messages. Accepts gpt-4 or gpt-3.5-turbo.