Noizu.OpenAI.Api.Edit (Noizu Labs: OpenAI v0.1.3)

Noizu.OpenAI.Api.Edit is a module that provides functionality for editing text using OpenAI's API.

This module offers one main function:

  1. edit/3 - Edits the given input text based on the specified instruction and options.

usage

Usage

{:ok, edit_response} = Noizu.OpenAI.Api.Edit.edit(input, instruction, options)

Link to this section Summary

Functions

Generates an edit-based completion using the OpenAI API.

Link to this section Types

Link to this type

edit_options()

@type edit_options() ::
  %{
    optional(:model) => Noizu.OpenAI.model_option(edit_supported_models()),
    optional(:completions | :n) => Noizu.OpenAI.completions_option(),
    optional(:temperature) => Noizu.OpenAI.temperature_option(),
    optional(:top_p) => Noizu.OpenAI.top_p_option(),
    optional(:stream) => Noizu.OpenAI.stream_option()
  }
  | Keyword.t()
Link to this type

edit_response()

@type edit_response() :: map()
Link to this type

edit_supported_models()

@type edit_supported_models() :: :"code-davinci-edit-001" | atom()

Link to this section Functions

Link to this function

edit(input, instruction, options \\ nil)

@spec edit(input :: String.t(), instruction :: String.t(), options :: edit_options()) ::
  {:ok, edit_response()} | {:error, term()}

Generates an edit-based completion using the OpenAI API.

parameters

Parameters

  • input: A string containing the input text
  • instruction: A string containing the editing instruction
  • options: An optional map or keyword list containing API options

returns

Returns

Returns a tuple {:ok, response} on successful API call, where response is a map containing the edited text. Returns {:error, term} on failure, where term contains error details.

example

Example

input = "The sun rises in the est."
instruction = "Fix the typo in this sentence."
{:ok, response} = Noizu.OpenAI.Api.Edit.edit(input, instruction)