Skip to content

Commit

Permalink
Update convert.go
Browse files Browse the repository at this point in the history
dont compile every time and dont !="" because of +
  • Loading branch information
xqdoo00o authored May 14, 2024
1 parent 1cd3a10 commit 1a812cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions conversion/requests/chatgpt/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
arkose "github.com/xqdoo00o/funcaptcha"
)

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

func ConvertAPIRequest(api_request official_types.APIRequest, account string, secret *tokens.Secret, deviceId string, requireArk bool, dx string, proxy string) chatgpt_types.ChatGPTRequest {
chatgpt_request := chatgpt_types.NewChatGPTRequest()
var api_version int
Expand All @@ -22,15 +24,13 @@ func ConvertAPIRequest(api_request official_types.APIRequest, account string, se
chatgpt_request.Model = "text-davinci-002-render-sha"
} else if strings.HasPrefix(api_request.Model, "gpt-4") {
api_version = 4

re := regexp.MustCompile(`^(gpt-4|gpt-4o)(?:-gizmo-g-(\w+))?$`)
matches := re.FindStringSubmatch(api_request.Model)
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] != "" {
if len(matches) == 3 {
chatgpt_request.ConversationMode.Kind = "gizmo_interaction"
chatgpt_request.ConversationMode.GizmoId = "g-" + matches[2]
}
Expand Down

0 comments on commit 1a812cf

Please sign in to comment.