/
models.go
83 lines (74 loc) · 3.08 KB
/
models.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package gpt3
// EngineObject contained in an engine reponse
type EngineObject struct {
ID string `json:"id"`
Object string `json:"object"`
Owner string `json:"owner"`
Ready bool `json:"ready"`
}
// EnginesResponse is returned from the Engines API
type EnginesResponse struct {
Data []EngineObject `json:"data"`
Object string `json:"object"`
}
// CompletionRequest is a request for the completions API
type CompletionRequest struct {
// The engine ID
EngineID string `json:"engine_id,omitempty"`
// A list of string prompts to use.
// TODO there are other prompt types here for using token integers that we could add support for.
Prompt []string `json:"prompt"`
// How many tokens to complete up to. Max of 512
MaxTokens *int `json:"max_tokens,omitempty"`
// Sampling temperature to use
Temperature *float32 `json:"temperature,omitempty"`
// Alternative to temperature for nucleus sampling
TopP *float32 `json:"top_p,omitempty"`
// How many choice to create for each prompt
N *float32 `json:"n"`
// Include the probabilities of most likely tokens
LogProbs *int `json:"logprobs"`
// Echo back the prompt in addition to the completion
Echo bool `json:"echo"`
// Up to 4 sequences where the API will stop generating tokens. Response will not contain the stop sequence.
Stop []string `json:"stop,omitempty"`
// PresencePenalty number between 0 and 1 that penalizes tokens that have already appeared in the text so far.
PresencePenalty float32 `json:"presence_penalty"`
// FrequencyPenalty number between 0 and 1 that penalizes tokens on existing frequency in the text so far.
FrequencyPenalty float32 `json:"presence_penalty"`
// Whether to stream back results or not. Don't set this value in the request yourself
// as it will be overriden depending on if you use CompletionStream or Completion methods.
Stream bool `json:"stream,omitempty"`
}
// CompletionResponseChoice is one of the choices returned in the response to the Completions API
type CompletionResponseChoice struct {
Text string `json:"text"`
Index int `json:"index"`
LogProbs *int `json:"logprobs"`
FinishReason string `json:"finish_reason"`
}
// CompletionResponse is the full response from a request to the completions API
type CompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
Choices []CompletionResponseChoice `json:"choices"`
}
// SearchRequest is a request for the document search API
type SearchRequest struct {
EngineID string `json:"engine_id"`
Documents []string `json:"documents"`
Query string `json:"query"`
}
// SearchData is a single search result from the document search API
type SearchData struct {
Document int `json:"document"`
Object string `json:"search_resulet"`
Score float64 `json:"score"`
}
// SearchResponse is the full response from a request to the document search API
type SearchResponse struct {
Data []SearchData `json:"data"`
Object string `json:"object"`
}