Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
change back to gen arkose token online to fix 403 (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
linweiyuan committed Jun 21, 2023
1 parent f3fd63f commit 2435a40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion api/chatgpt/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,21 @@ func CreateConversation(c *gin.Context) {
}

if request.Model == gpt4Model || request.Model == gpt4BrowsingModel || request.Model == gpt4PluginsModel {
request.ArkoseToken = fmt.Sprintf(arkoseTokenTemplate, api.GenerateRandomString(17), api.GenerateRandomString(10), gpt4ArkoseTokenPublicKey, api.GenerateRandomNumber())
formParams := fmt.Sprintf(
"public_key=%s",
gpt4ArkoseTokenPublicKey,
)
req, _ := http.NewRequest(http.MethodPost, gpt4TokenUrl, strings.NewReader(formParams))
req.Header.Set("Content-Type", api.ContentType)
resp, err := api.Client.Do(req)
if err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, api.ReturnMessage(err.Error()))
return
}

responseMap := make(map[string]string)
json.NewDecoder(resp.Body).Decode(&responseMap)
request.ArkoseToken = responseMap["token"]
}

resp, done := sendConversationRequest(c, request)
Expand Down
2 changes: 1 addition & 1 deletion api/chatgpt/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
gpt4BrowsingModel = "gpt-4-browsing"
gpt4PluginsModel = "gpt-4-plugins"
gpt4ArkoseTokenPublicKey = "35536E1E-65B4-4D96-9D97-6ADB7EFF8147"
arkoseTokenTemplate = `%s.%s|r=us-east-1|meta=3|meta_width=300|metabgclr=transparent|metaiconclr=%%23555555|guitextcolor=%%23000000|pk=%s|at=40|rid=%d|ag=101|cdn_url=https%%3A%%2F%%2Ftcr9i.chat.openai.com%%2Fcdn%%2Ffc|lurl=https%%3A%%2F%%2Faudio-us-east-1.arkoselabs.com|surl=https%%3A%%2F%%2Ftcr9i.chat.openai.com|smurl=https%%3A%%2F%%2Ftcr9i.chat.openai.com%%2Fcdn%%2Ffc%%2Fassets%%2Fstyle-manager`
gpt4TokenUrl = "https://tcr9i.chat.openai.com/fc/gt2/public_key/" + gpt4ArkoseTokenPublicKey

actionContinue = "continue"
responseTypeMaxTokens = "max_tokens"
Expand Down

0 comments on commit 2435a40

Please sign in to comment.