Skip to content

Commit

Permalink
feat gpts for normal
Browse files Browse the repository at this point in the history
  • Loading branch information
xqdoo00o committed May 24, 2024
1 parent e69e3d8 commit ff409b6
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions conversion/requests/chatgpt/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,24 @@ import (
"strings"
)

var gpt4Regexp = regexp.MustCompile(`^(gpt-4|gpt-4o)(?:-gizmo-g-(\w+))?$`)
var gptsRegexp = regexp.MustCompile(`-gizmo-g-(\w+)`)

func ConvertAPIRequest(api_request official_types.APIRequest, account string, secret *tokens.Secret, deviceId string, proxy string) chatgpt_types.ChatGPTRequest {
chatgpt_request := chatgpt_types.NewChatGPTRequest()
var api_version int
if strings.HasPrefix(api_request.Model, "gpt-3.5") {
api_version = 3
chatgpt_request.Model = "text-davinci-002-render-sha"
} else if strings.HasPrefix(api_request.Model, "gpt-4") {
api_version = 4
matches := gpt4Regexp.FindStringSubmatch(api_request.Model)
if len(matches) > 0 {
chatgpt_request.Model = matches[1]
} else {
chatgpt_request.Model = "gpt-4"
}
if len(matches) == 3 && matches[2] != "" {
chatgpt_request.ConversationMode.Kind = "gizmo_interaction"
chatgpt_request.ConversationMode.GizmoId = "g-" + matches[2]
chatgpt_request.Model = "gpt-4"
if strings.HasPrefix(api_request.Model, "gpt-4o") {
chatgpt_request.Model = "gpt-4o"
}
}
ifMultimodel := api_version == 4
matches := gptsRegexp.FindStringSubmatch(api_request.Model)
if len(matches) == 2 {
chatgpt_request.ConversationMode.Kind = "gizmo_interaction"
chatgpt_request.ConversationMode.GizmoId = "g-" + matches[1]
}
ifMultimodel := secret.Token != ""
for _, api_message := range api_request.Messages {
if api_message.Role == "system" {
api_message.Role = "critic"
Expand Down

0 comments on commit ff409b6

Please sign in to comment.