-
Notifications
You must be signed in to change notification settings - Fork 1
/
request.go
155 lines (134 loc) · 6.57 KB
/
request.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package openai
import "github.com/KirillMironov/openai/internal/formdata"
type CompletionRequest struct {
Model string `json:"model"`
Prompt []string `json:"prompt,omitempty"`
Suffix string `json:"suffix,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
N int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Logprobs int `json:"logprobs,omitempty"`
Echo bool `json:"echo,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
BestOf int `json:"best_of,omitempty"`
LogitBias map[string]int `json:"logit_bias,omitempty"`
User string `json:"user,omitempty"`
}
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []ChatCompletionRequestMessage `json:"messages"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
N int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
LogitBias map[string]int `json:"logit_bias,omitempty"`
User string `json:"user,omitempty"`
}
type EditRequest struct {
Model string `json:"model"`
Input string `json:"input,omitempty"`
Instruction string `json:"instruction"`
N int `json:"n,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
}
type ImageSize string
const (
ImageSize256x256 ImageSize = "256x256"
ImageSize512x512 ImageSize = "512x512"
ImageSize1024x1024 ImageSize = "1024x1024"
)
type ImageResponseFormat string
const (
ImageResponseFormatURL ImageResponseFormat = "url"
ImageResponseFormatB64JSON ImageResponseFormat = "b64_json"
)
type ImageRequest struct {
Prompt string `json:"prompt"`
N int `json:"n,omitempty"`
Size ImageSize `json:"size,omitempty"`
ResponseFormat ImageResponseFormat `json:"response_format,omitempty"`
User string `json:"user,omitempty"`
}
type ImageEditRequest struct {
Image formdata.File `form:"image"`
Mask formdata.File `form:"mask,omitempty"`
Prompt string `form:"prompt"`
N int `form:"n,omitempty"`
Size ImageSize `form:"size,omitempty"`
ResponseFormat ImageResponseFormat `form:"response_format,omitempty"`
User string `form:"user,omitempty"`
}
type ImageVariationRequest struct {
Image formdata.File `form:"image"`
N int `form:"n,omitempty"`
Size ImageSize `form:"size,omitempty"`
ResponseFormat ImageResponseFormat `form:"response_format,omitempty"`
User string `form:"user,omitempty"`
}
type EmbeddingRequest struct {
Model string `json:"model"`
Input []string `json:"input"`
User string `json:"user,omitempty"`
}
type TranscriptionResponseFormat string
const (
TranscriptionResponseFormatJSON TranscriptionResponseFormat = "json"
TranscriptionResponseFormatText TranscriptionResponseFormat = "text"
TranscriptionResponseFormatSRT TranscriptionResponseFormat = "srt"
TranscriptionResponseFormatVerboseJSON TranscriptionResponseFormat = "verbose_json"
TranscriptionResponseFormatVTT TranscriptionResponseFormat = "vtt"
)
type TranscriptionRequest struct {
File formdata.File `form:"file"`
Model string `json:"model"`
Prompt string `json:"prompt,omitempty"`
ResponseFormat TranscriptionResponseFormat `json:"response_format,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Language string `json:"language,omitempty"`
}
type TranslationResponseFormat string
const (
TranslationResponseFormatJSON TranslationResponseFormat = "json"
TranslationResponseFormatText TranslationResponseFormat = "text"
TranslationResponseFormatSRT TranslationResponseFormat = "srt"
TranslationResponseFormatVerboseJSON TranslationResponseFormat = "verbose_json"
TranslationResponseFormatVTT TranslationResponseFormat = "vtt"
)
type TranslationRequest struct {
File formdata.File `form:"file"`
Model string `json:"model"`
Prompt string `json:"prompt,omitempty"`
ResponseFormat TranslationResponseFormat `json:"response_format,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
}
type UploadFileRequest struct {
File formdata.File `form:"file"`
Purpose string `form:"purpose"`
}
type FineTuneRequest struct {
TrainingFile string `json:"training_file"`
ValidationFile string `json:"validation_file,omitempty"`
Model string `json:"model,omitempty"`
NEpochs int `json:"n_epochs,omitempty"`
BatchSize int `json:"batch_size,omitempty"`
LearningRateMultiplier float64 `json:"learning_rate_multiplier,omitempty"`
PromptLossWeight float64 `json:"prompt_loss_weight,omitempty"`
ComputeClassificationMetrics bool `json:"compute_classification_metrics,omitempty"`
ClassificationNClasses int `json:"classification_n_classes,omitempty"`
ClassificationPositiveClass string `json:"classification_positive_class,omitempty"`
ClassificationBetas []float64 `json:"classification_betas,omitempty"`
Suffix string `json:"suffix,omitempty"`
}
type ModerationRequest struct {
Input []string `json:"input"`
Model string `json:"model,omitempty"`
}