Skip to content

Commit

Permalink
feat: add support for gpt4 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush6624 authored Mar 28, 2023
1 parent acfe8cf commit 504d32a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Go-ChatGPT is an open-source GoLang client for ChatGPT, a large language model t
- [x] Easy-to-use GoLang client for ChatGPT
- [x] Sends text to ChatGPT and receives a response
- [x] Support custom model and parameters
- [x] Supports GPT3.5 and GPT4 models


## Installation
Expand Down
6 changes: 5 additions & 1 deletion chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ 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"
)

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

if req.Model != GPT35Turbo && req.Model != GPT35Turbo0301 {
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
}

Expand Down
2 changes: 1 addition & 1 deletion examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
log.Println(string(a))

res, err = c.Send(ctx, &chatgpt.ChatCompletionRequest{
Model: chatgpt.GPT35Turbo,
Model: chatgpt.GPT4,
Messages: []chatgpt.ChatMessage{
{
Role: chatgpt.ChatGPTModelRoleSystem,
Expand Down

0 comments on commit 504d32a

Please sign in to comment.