Skip to content

Commit

Permalink
适配4o 内置arkose
Browse files Browse the repository at this point in the history
  • Loading branch information
gcslaoli committed May 14, 2024
1 parent 1c67a93 commit c2ee037
Show file tree
Hide file tree
Showing 28 changed files with 2,343 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'
services:
mysql:
image: mysql:8
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
command: --mysql-native-password=ON --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always
# network_mode: host
volumes:
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Api2backend(r *ghttp.Request) {
}
officialAccessToken := utility.AccessTokenFormSession(officialSession)

UpStream := config.CHATPROXY(ctx)
UpStream := config.CHATPROXY
u, _ := url.Parse(UpStream)
proxy := httputil.NewSingleHostReverseProxy(u)
proxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, e error) {
Expand Down
76 changes: 3 additions & 73 deletions api/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,8 @@ func Index(r *ghttp.Request) {
return
}
model := r.Get("model").String()
props := `
{
"props": {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "[email protected]",
"email": "[email protected]",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
"iat": 2699699364,
"mfa": false,
"groups": [],
"intercom_hash": "30fd0a0ada1c07ce526be7c3d54c22904b80fa7e2713d978630e979e4315cf67"
},
"serviceStatus": {},
"userCountry": "US",
"serviceAnnouncement": {
"paid": {},
"public": {}
},
"serverPrimedAllowBrowserStorageValue": true,
"canManageBrowserStorage": false,
"ageVerificationDeadline": null,
"showCookieConsentBanner": false
},
"__N_SSP": true
},
"page": "/[[...default]]",
"query": {},
"buildId": "wtXFegAXt6bfbujLr1e7S",
"assetPrefix": "",
"isFallback": false,
"gssp": true,
"scriptLoader": []
}`

propsJson := gjson.New(props)
propsJson := gjson.New(Props)
if model != "" {
propsJson.Set("query.model", model)
}
Expand All @@ -80,42 +43,9 @@ func C(r *ghttp.Request) {
convId := r.GetRouter("convId").String()

g.Log().Debug(r.GetCtx(), "convId", convId)
props := `
{
"props": {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "[email protected]",
"email": "[email protected]",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
"iat": 2699699364,
"mfa": false,
"groups": []
},
"serviceStatus": {},
"userCountry": "US",
"serviceAnnouncement": { "paid": {}, "public": {} },
"serverPrimedAllowBrowserStorageValue": true,
"canManageBrowserStorage": false,
"ageVerificationDeadline": null,
"showCookieConsentBanner": false
},
"__N_SSP": true
},
"page": "/[[...default]]",
"query": { "default": ["c", "98d86ec9-fa8b-42ba-98e8-ffd6c1d6cae4"] },
"buildId": "wtXFegAXt6bfbujLr1e7S",
"assetPrefix": "",
"isFallback": false,
"gssp": true,
"scriptLoader": []
}
`

propsJson := gjson.New(props)
propsJson := gjson.New(Props)
propsJson.Set("query.default.0", "c")
propsJson.Set("query.default.1", convId)
propsJson.Set("buildId", config.BuildId)
propsJson.Set("assetPrefix", config.AssetPrefix)
Expand Down
2 changes: 1 addition & 1 deletion api/next.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ProxyNext(r *ghttp.Request) {
ctx := r.Context()
officalSession := gjson.New(r.Session.MustGet("offical-session"))
refreshCookie := officalSession.Get("refreshCookie").String()
u, _ := url.Parse(config.CHATPROXY(ctx))
u, _ := url.Parse(config.CHATPROXY)
proxy := httputil.NewSingleHostReverseProxy(u)
proxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, e error) {
writer.WriteHeader(http.StatusBadGateway)
Expand Down
2 changes: 1 addition & 1 deletion api/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Session(r *ghttp.Request) {
return
}
officialSession := gjson.New(record["officialSession"].String())
getSessionUrl := config.CHATPROXY(ctx) + "/getsession"
getSessionUrl := config.CHATPROXY + "/getsession"
refreshCookie := officialSession.Get("refreshCookie").String()
sessionVar := g.Client().SetHeader("authkey", config.AUTHKEY(ctx)).PostVar(ctx, getSessionUrl, g.Map{
"username": record["email"].String(),
Expand Down
Loading

0 comments on commit c2ee037

Please sign in to comment.