choonkeat / elm-openai / OpenAI.Edits

Given a prompt and an instruction, the model will return an edited version of the prompt.

See https://beta.openai.com/docs/api-reference/edits

create : Input -> Ext.Http.TaskInput (Ext.Http.Error String) Output

https://beta.openai.com/docs/api-reference/edits/create

create
    { model = OpenAI.ModelID.TextDavinciEdit001
    , input = "The quick brown fox jumps over the lazy dog."
    , instruction = "Make it more formal."
    , n = Just 2
    , temperature = Nothing
    , top_p = Nothing
    }
    |> OpenAI.withConfig cfg
    |> Http.task
-- > Task.succeed
-- >     { choices =
-- >         [ { index = 0, text = "The quick brown fox jumps over the lazy dog.\nOne day she was on the roof\nLooking for one thing that the the chicken stole.\nIt was long green and has a big nose.\n" }
-- >         , { index = 1, text = "The quick brown fox jumps over the lazy dog. I am going to Germany tonight.\n" }
-- >         ]
-- >     , created = Posix ...
-- >     , object = "edit"
-- >     , usage = { completion_tokens = 79, prompt_tokens = 27, total_tokens = 106 }
-- >     }


type alias Input =
{ model : OpenAI.ModelID.ModelID
, input : String
, instruction : String
, n : Maybe Basics.Int
, temperature : Maybe Basics.Float
, top_p : Maybe Basics.Float 
}


type alias Output =
{ object : String
, created : Time.Posix
, usage : OpenAI.Common.Usage
, choices : List Choice 
}


type alias Choice =
{ text : String
, index : Basics.Int 
}