diff --git a/conversion/requests/chatgpt/convert.go b/conversion/requests/chatgpt/convert.go index 4187e53..daf12d4 100644 --- a/conversion/requests/chatgpt/convert.go +++ b/conversion/requests/chatgpt/convert.go @@ -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"