- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathedits.go
53 lines (46 loc) · 1.42 KB
/
edits.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package openai
import (
"context"
"fmt"
"net/http"
)
// EditsRequest represents a request structure for Edits API.
typeEditsRequeststruct {
Model*string`json:"model,omitempty"`
Inputstring`json:"input,omitempty"`
Instructionstring`json:"instruction,omitempty"`
Nint`json:"n,omitempty"`
Temperaturefloat32`json:"temperature,omitempty"`
TopPfloat32`json:"top_p,omitempty"`
}
// EditsChoice represents one of possible edits.
typeEditsChoicestruct {
Textstring`json:"text"`
Indexint`json:"index"`
}
// EditsResponse represents a response structure for Edits API.
typeEditsResponsestruct {
Objectstring`json:"object"`
Createdint64`json:"created"`
UsageUsage`json:"usage"`
Choices []EditsChoice`json:"choices"`
httpHeader
}
// Edits Perform an API call to the Edits endpoint.
/* Deprecated: Users of the Edits API and its associated models (e.g., text-davinci-edit-001 or code-davinci-edit-001)
will need to migrate to GPT-3.5 Turbo by January 4, 2024.
You can use CreateChatCompletion or CreateChatCompletionStream instead.
*/
func (c*Client) Edits(ctx context.Context, requestEditsRequest) (responseEditsResponse, errerror) {
req, err:=c.newRequest(
ctx,
http.MethodPost,
c.fullURL("/edits", withModel(fmt.Sprint(request.Model))),
withBody(request),
)
iferr!=nil {
return
}
err=c.sendRequest(req, &response)
return
}