Skip to content

Commit

Permalink
feat: Update new models
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush6624 committed Jul 8, 2023
1 parent 7d5dfa2 commit b7e25fa
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,26 @@ import (
type ChatGPTModel string

const (
GPT35Turbo ChatGPTModel = "gpt-3.5-turbo"
GPT35Turbo0301 ChatGPTModel = "gpt-3.5-turbo-0301"
GPT4 ChatGPTModel = "gpt-4"
GPT4_0314 ChatGPTModel = "gpt-4-0314"
GPT4_32k ChatGPTModel = "gpt-4-32k"
GPT4_32k_0314 ChatGPTModel = "gpt-4-32k-0314"
GPT35Turbo ChatGPTModel = "gpt-3.5-turbo"

// Deprecated: Use gpt-3.5-turbo-0613 instead, model will discontinue on 09/13/2023
GPT35Turbo0301 ChatGPTModel = "gpt-3.5-turbo-0301"

GPT35Turbo0613 ChatGPTModel = "gpt-3.5-turbo-0613"
GPT35Turbo16k ChatGPTModel = "gpt-3.5-turbo-16k"
GPT35Turbo16k0613 ChatGPTModel = "gpt-3.5-turbo-16k-0613"
GPT4 ChatGPTModel = "gpt-4"

// Deprecated: Use gpt-4-0613 instead, model will discontinue on 09/13/2023
GPT4_0314 ChatGPTModel = "gpt-4-0314"

GPT4_0613 ChatGPTModel = "gpt-4-0613"
GPT4_32k ChatGPTModel = "gpt-4-32k"

// Deprecated: Use gpt-4-32k-0613 instead, model will discontinue on 09/13/2023
GPT4_32k_0314 ChatGPTModel = "gpt-4-32k-0314"

GPT4_32k_0613 ChatGPTModel = "gpt-4-32k-0613"
)

type ChatGPTModelRole string
Expand Down Expand Up @@ -143,8 +157,14 @@ func validate(req *ChatCompletionRequest) error {
return chatgpt_errors.ErrNoMessages
}

if req.Model != GPT35Turbo && req.Model != GPT35Turbo0301 && req.Model != GPT4 && req.Model != GPT4_0314 && req.Model != GPT4_32k && req.Model != GPT4_32k_0314 {
return chatgpt_errors.ErrInvalidModel
allowedModels := []ChatGPTModel{
GPT35Turbo, GPT35Turbo0301, GPT35Turbo0613, GPT35Turbo16k, GPT35Turbo16k0613, GPT4, GPT4_0314, GPT4_0613, GPT4_32k, GPT4_32k_0314, GPT4_32k_0613,
}

for _, model := range allowedModels {
if req.Model != model {
return chatgpt_errors.ErrInvalidModel
}
}

for _, message := range req.Messages {
Expand Down

0 comments on commit b7e25fa

Please sign in to comment.