Skip to content

Commit

Permalink
chore: remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
madoka committed Apr 3, 2024
1 parent fde3f53 commit b8eb5f3
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 40 deletions.
29 changes: 0 additions & 29 deletions conversion/requests/chatgpt/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,20 @@ package chatgpt
import (
chatgpt_types "aurora/typings/chatgpt"
official_types "aurora/typings/official"
"fmt"
"strings"

arkose "github.com/xqdoo00o/funcaptcha"
)

func ConvertAPIRequest(api_request official_types.APIRequest, puid string, requireArk bool, 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
chatgpt_request.Model = api_request.Model
// Cover some models like gpt-4-32k
if len(api_request.Model) >= 7 && api_request.Model[6] >= 48 && api_request.Model[6] <= 57 {
chatgpt_request.Model = "gpt-4"
}
}
if requireArk {
token, err := arkose.GetOpenAIToken(api_version, puid, proxy)
if err == nil {
chatgpt_request.ArkoseToken = token
} else {
fmt.Println("Error getting Arkose token: ", err)
}
}
if api_request.PluginIDs != nil {
chatgpt_request.PluginIDs = api_request.PluginIDs
chatgpt_request.Model = "gpt-4-plugins"
Expand All @@ -43,18 +29,3 @@ func ConvertAPIRequest(api_request official_types.APIRequest, puid string, requi
}
return chatgpt_request
}

func RenewTokenForRequest(request *chatgpt_types.ChatGPTRequest, puid string, proxy string) {
var api_version int
if strings.HasPrefix(request.Model, "gpt-4") {
api_version = 4
} else {
api_version = 3
}
token, err := arkose.GetOpenAIToken(api_version, puid, proxy)
if err == nil {
request.ArkoseToken = token
} else {
fmt.Println("Error getting Arkose token: ", err)
}
}
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ module aurora
go 1.21

require (
github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd
github.com/bogdanfinn/fhttp v0.5.24
github.com/bogdanfinn/tls-client v1.6.1
github.com/gin-gonic/gin v1.9.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.1
github.com/joho/godotenv v1.5.1
github.com/xqdoo00o/funcaptcha v0.0.0-20240313153914-4ab805804232
)

require (
Expand Down
5 changes: 1 addition & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd h1:oIpfrRhD7Jus41dotbK+SQjWSFRnf1cLZUYCZpF/o/4=
github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd/go.mod h1:0yO7neMeJLvKk/B/fq5votDY8rByrOPDubpvU+6saKo=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/bogdanfinn/fhttp v0.5.24 h1:OlyBKjvJp6a3TotN3wuj4mQHHRbfK7QUMrzCPOZGhRc=
Expand Down Expand Up @@ -28,6 +26,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
Expand Down Expand Up @@ -85,8 +84,6 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/xqdoo00o/funcaptcha v0.0.0-20240313153914-4ab805804232 h1:K8+8YdWdDzmmhVqNflEXV4RLpZPf56wwxo0k0nAtQO4=
github.com/xqdoo00o/funcaptcha v0.0.0-20240313153914-4ab805804232/go.mod h1:7aCyoW5MHDUsoooMVLqKe0F7W9HMPUvDG3bXqw++8XA=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
Expand Down
3 changes: 0 additions & 3 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ func nightmare(c *gin.Context) {
translated_request.Action = "continue"
translated_request.ConversationID = continue_info.ConversationID
translated_request.ParentMessageID = continue_info.ParentID
if chat_require.Arkose.Required {
chatgpt_request_converter.RenewTokenForRequest(&translated_request, puid, proxy_url)
}
response, err = chatgpt.POSTconversation(translated_request, token, puid, chat_require.Token, proxy_url, oidDid)
if err != nil {
c.JSON(500, gin.H{
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"aurora/internal/tokens"
"github.com/acheong08/endless"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"os"
Expand Down Expand Up @@ -39,5 +38,7 @@ func main() {

router.OPTIONS("/v1/chat/completions", optionsHandler)
router.POST("/v1/chat/completions", nightmare)
endless.ListenAndServe(HOST+":"+PORT, router)

router.Run(HOST + ":" + PORT)

}

0 comments on commit b8eb5f3

Please sign in to comment.