OpenAI.Chat (openai_client v0.5.3)

Given a chat conversation, the model will return a chat completion response.

https://platform.openai.com/docs/api-reference/chat

Link to this section Summary

Functions

Creates a completion for the chat message

Link to this section Types

Link to this type

create_completion_params()

@type create_completion_params() :: %{
  :model => String.t(),
  :messages => [message()],
  optional(:temperature) => float(),
  optional(:top_p) => float(),
  optional(:n) => integer(),
  optional(:stream) => boolean(),
  optional(:stop) => String.t() | [String.t()],
  optional(:max_tokens) => integer(),
  optional(:presence_penalty) => float(),
  optional(:frequency_penalty) => float(),
  optional(:logit_bias) => %{required(String.t()) => float()},
  optional(:response_format) => response_format(),
  optional(:tools) => [tool()],
  optional(:tool_choice) => String.t() | tool_choice(),
  optional(:user) => String.t()
}
@type message() :: %{role: String.t(), content: String.t()}
Link to this type

response_format()

@type response_format() :: %{:type => String.t(), optional(:json_schema) => map()}
@type tool() :: %{type: String.t(), function: tool_function()}
Link to this type

tool_choice()

@type tool_choice() :: %{type: String.t(), function: tool_function()}
Link to this type

tool_choice_function()

@type tool_choice_function() :: %{name: String.t()}
Link to this type

tool_function()

@type tool_function() :: %{
  :name => String.t(),
  optional(:description) => String.t(),
  optional(:parameters) => map()
}

Link to this section Functions

Link to this function

create_completion(client, params, opts \\ [])

Creates a completion for the chat message