Skip to content

Commit b7e25fa

Browse files
committed
feat: Update new models
1 parent 7d5dfa2 commit b7e25fa

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

chat.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,26 @@ import (
1212
type ChatGPTModel string
1313

1414
const (
15-
GPT35Turbo ChatGPTModel = "gpt-3.5-turbo"
16-
GPT35Turbo0301 ChatGPTModel = "gpt-3.5-turbo-0301"
17-
GPT4 ChatGPTModel = "gpt-4"
18-
GPT4_0314 ChatGPTModel = "gpt-4-0314"
19-
GPT4_32k ChatGPTModel = "gpt-4-32k"
20-
GPT4_32k_0314 ChatGPTModel = "gpt-4-32k-0314"
15+
GPT35Turbo ChatGPTModel = "gpt-3.5-turbo"
16+
17+
// Deprecated: Use gpt-3.5-turbo-0613 instead, model will discontinue on 09/13/2023
18+
GPT35Turbo0301 ChatGPTModel = "gpt-3.5-turbo-0301"
19+
20+
GPT35Turbo0613 ChatGPTModel = "gpt-3.5-turbo-0613"
21+
GPT35Turbo16k ChatGPTModel = "gpt-3.5-turbo-16k"
22+
GPT35Turbo16k0613 ChatGPTModel = "gpt-3.5-turbo-16k-0613"
23+
GPT4 ChatGPTModel = "gpt-4"
24+
25+
// Deprecated: Use gpt-4-0613 instead, model will discontinue on 09/13/2023
26+
GPT4_0314 ChatGPTModel = "gpt-4-0314"
27+
28+
GPT4_0613 ChatGPTModel = "gpt-4-0613"
29+
GPT4_32k ChatGPTModel = "gpt-4-32k"
30+
31+
// Deprecated: Use gpt-4-32k-0613 instead, model will discontinue on 09/13/2023
32+
GPT4_32k_0314 ChatGPTModel = "gpt-4-32k-0314"
33+
34+
GPT4_32k_0613 ChatGPTModel = "gpt-4-32k-0613"
2135
)
2236

2337
type ChatGPTModelRole string
@@ -143,8 +157,14 @@ func validate(req *ChatCompletionRequest) error {
143157
return chatgpt_errors.ErrNoMessages
144158
}
145159

146-
if req.Model != GPT35Turbo && req.Model != GPT35Turbo0301 && req.Model != GPT4 && req.Model != GPT4_0314 && req.Model != GPT4_32k && req.Model != GPT4_32k_0314 {
147-
return chatgpt_errors.ErrInvalidModel
160+
allowedModels := []ChatGPTModel{
161+
GPT35Turbo, GPT35Turbo0301, GPT35Turbo0613, GPT35Turbo16k, GPT35Turbo16k0613, GPT4, GPT4_0314, GPT4_0613, GPT4_32k, GPT4_32k_0314, GPT4_32k_0613,
162+
}
163+
164+
for _, model := range allowedModels {
165+
if req.Model != model {
166+
return chatgpt_errors.ErrInvalidModel
167+
}
148168
}
149169

150170
for _, message := range req.Messages {

0 commit comments

Comments
 (0)