Skip to content

Commit

Permalink
v1.7.4 fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lanqian528 committed Dec 6, 2024
1 parent e223c69 commit 8e7acbd
Show file tree
Hide file tree
Showing 5 changed files with 906 additions and 443 deletions.
15 changes: 8 additions & 7 deletions gateway/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def check_account(request: Request):
for key in check_account_info.get("accounts", {}).keys():
account_id = check_account_info["accounts"][key]["account"]["account_id"]
globals.seed_map[token]["user_id"] = \
check_account_info["accounts"][key]["account"]["account_user_id"].split("__")[0]
check_account_info["accounts"][key]["account"]["account_user_id"].split("__")[0]
check_account_info["accounts"][key]["account"]["account_user_id"] = f"user-chatgpt__{account_id}"
with open(globals.SEED_MAP_FILE, "w", encoding="utf-8") as f:
json.dump(globals.seed_map, f, indent=4)
Expand Down Expand Up @@ -257,15 +257,17 @@ async def chat_conversations(request: Request):
fp = get_fp(req_token).copy()
proxy_url = fp.pop("proxy_url", None)
impersonate = fp.pop("impersonate", "safari15_3")
user_agent = fp.get("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0")
user_agent = fp.get("user-agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0")

host_url = random.choice(chatgpt_base_url_list) if chatgpt_base_url_list else "https://chatgpt.com"
proof_token = None
turnstile_token = None

headers = {
key: value for key, value in request.headers.items()
if (key.lower() not in ["host", "origin", "referer", "priority", "sec-ch-ua-platform", "sec-ch-ua", "sec-ch-ua-mobile", "oai-device-id"] and key.lower() not in headers_reject_list)
if (key.lower() not in ["host", "origin", "referer", "priority", "sec-ch-ua-platform", "sec-ch-ua",
"sec-ch-ua-mobile", "oai-device-id"] and key.lower() not in headers_reject_list)
}
headers.update(fp)
headers.update({"authorization": f"Bearer {access_token}"})
Expand All @@ -280,7 +282,7 @@ async def chat_conversations(request: Request):
p = get_requirements_token(config)
data = {'p': p}
r = await clients.post(f'{host_url}/backend-api/sentinel/chat-requirements', headers=headers, json=data,
timeout=10)
timeout=10)
resp = r.json()
turnstile = resp.get('turnstile', {})
turnstile_required = turnstile.get('required')
Expand Down Expand Up @@ -347,9 +349,8 @@ async def c_close(client, clients):
rheaders.update({"x-sign": x_sign})
if 'stream' in rheaders.get("content-type", ""):
conv_key = r.cookies.get("conv_key", "")
response = StreamingResponse(content_generator(r, token, history),
media_type=r.headers.get("content-type", ""),
background=background)
response = StreamingResponse(content_generator(r, token, history), headers=rheaders,
media_type=r.headers.get("content-type", ""), background=background)
response.set_cookie("conv_key", value=conv_key)
return response
else:
Expand Down
153 changes: 121 additions & 32 deletions templates/chatgpt.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html data-build="prod-29a8efc4cbe23593eaf2ae6b6f8f30a6385fe747" dir="ltr" class="">
<html data-build="prod-6c1c10ddd07526f6e92ca7103552be5eff2c8590-c" dir="ltr" class="">
<head>
<meta charSet="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
Expand All @@ -18,30 +18,34 @@
<meta property="og:title" content="ChatGPT"/>
<meta property="og:image" content="/assets/chatgpt-share-og-u7j5uyao.webp"/>
<meta property="og:url" content="https://chatgpt.com"/>
<link rel="modulepreload" href="/assets/manifest-02df4098.js"/>
<link rel="modulepreload" href="/assets/e5bysna0b8zobmag.js"/>
<link rel="modulepreload" href="/assets/dkrkpapzk8i632go.js"/>
<link rel="modulepreload" href="/assets/j6gkove76o4ch0ty.js"/>
<link rel="modulepreload" href="/assets/fow2c4yq3c8klomi.js"/>
<link rel="modulepreload" href="/assets/bf2p2f1vepq4y3f7.js"/>
<link rel="modulepreload" href="/assets/efbm65hm6xsu7gia.js"/>
<link rel="modulepreload" href="/assets/fnh1ee9l40s79ybh.js"/>
<link rel="modulepreload" href="/assets/ey5apunl1vnvf9g5.js"/>
<link rel="modulepreload" href="/assets/ivsfom077coy2e1x.js"/>
<link rel="modulepreload" href="/assets/ofdx6gir03c2dglj.js"/>
<link rel="modulepreload" href="/assets/dgwshraa8ui7irnp.js"/>
<link rel="modulepreload" href="/assets/znrwq6qdoakbx8c5.js"/>
<link rel="modulepreload" href="/assets/ipumxevpyo0r1zke.js"/>
<link rel="modulepreload" href="/assets/jqqo55reqowwgoc4.js"/>
<link rel="modulepreload" href="/assets/dkptqlxvdk2bhhas.js"/>
<link rel="modulepreload" href="/assets/mwbuo0yv1rlpzhci.js"/>
<link rel="modulepreload" href="/assets/ixhgxacwo4rec3g4.js"/>
<link rel="modulepreload" href="/assets/ohjx34ealw57wtov.js"/>
<link rel="modulepreload" href="/assets/ffzyzw8q2vjgtytc.js"/>
<link rel="modulepreload" href="/assets/otr73oks8k0fyvxy.js"/>
<link rel="modulepreload" href="/assets/nklvdpoxrgpd3hmb.js"/>
<link rel="modulepreload" href="/assets/manifest-a231f861.js"/>
<link rel="modulepreload" href="/assets/d6whfiv7obppelxo.js"/>
<link rel="modulepreload" href="/assets/ejdu8vtqp60hjx62.js"/>
<link rel="modulepreload" href="/assets/m6sx6uqoei0wugj3.js"/>
<link rel="modulepreload" href="/assets/nj07rjsuicmjw8r6.js"/>
<link rel="modulepreload" href="/assets/jbzdfqf5ym1dx59x.js"/>
<link rel="modulepreload" href="/assets/b1nqabmqcjk22xko.js"/>
<link rel="modulepreload" href="/assets/dl66vcpxqe3918vb.js"/>
<link rel="modulepreload" href="/assets/nszjq2j8gm3g0ynz.js"/>
<link rel="modulepreload" href="/assets/e39h10z4kni4cm67.js"/>
<link rel="modulepreload" href="/assets/ji0i5o7k5q3xmwpm.js"/>
<link rel="modulepreload" href="/assets/g6bsedzmfi1fmxzy.js"/>
<link rel="modulepreload" href="/assets/6j57s64xp3xwg24a.js"/>
<link rel="modulepreload" href="/assets/luguep56a1o7w3v1.js"/>
<link rel="modulepreload" href="/assets/e080e0qg3mqm03cb.js"/>
<link rel="modulepreload" href="/assets/fa8wh6k6n9sn7i0z.js"/>
<link rel="modulepreload" href="/assets/edk7minuwhmsqyuj.js"/>
<link rel="modulepreload" href="/assets/j93vp6b256swfbio.js"/>
<link rel="modulepreload" href="/assets/mocvtad3a8xfyk6m.js"/>
<link rel="modulepreload" href="/assets/kti8503kmjnx0fm9.js"/>
<link rel="modulepreload" href="/assets/l5tqsqrx5nivymbr.js"/>
<link rel="modulepreload" href="/assets/emo1akz0mz0yw38r.js"/>
<link rel="modulepreload" href="/assets/marjj918ldbi7qbf.js"/>
<link rel="modulepreload" href="/assets/pak9g14u94oe41fd.js"/>
<link rel="modulepreload" href="/assets/kbz3uoet7ef1lv40.js"/>
<link rel="modulepreload" href="/assets/mwj83gxumd1zqfgp.js"/>
<link rel="modulepreload" href="/assets/jjr9on9cxlrbskjq.js"/>
<link rel="stylesheet" href="/assets/root-k8yvx6b6.css"/>
<link rel="stylesheet" href="/assets/root-o724tfzz.css"/>
<link rel="stylesheet" href="/assets/conversation-small-lkohtmkm.css"/>
</head>
<body class="">
Expand Down Expand Up @@ -150,14 +154,13 @@ <h1 class="result-streaming absolute left-full transition-opacity" style="opacit
<div class="flex justify-center"></div>
<form class="w-full" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="radix-:Ruuijqaaklj5:" data-state="closed">
<div class="relative flex h-full max-w-full flex-1 flex-col">
<div class="relative h-0"></div>
<div class="group relative flex w-full items-center">
<div id="composer-background" class="flex w-full cursor-text flex-col rounded-3xl px-2.5 py-1 transition-colors contain-inline-size bg-[#f4f4f4] dark:bg-token-main-surface-secondary">
<div class="flex min-h-[44px] items-center px-2">
<div class="max-w-full flex-1">
<div class="_prosemirror-parent_15ceg_1 text-token-text-primary max-h-[25dvh] max-h-52 overflow-auto default-browser">
<textarea class="block h-10 w-full resize-none border-0 bg-transparent px-0 py-2 text-token-text-primary placeholder:text-token-text-secondary" autofocus="" placeholder="Message ChatGPT"></textarea>
<script nonce="e92906e6-e5fd-444f-803b-dd857bdafea6">
<script nonce="cdf9b650-861c-444c-b543-6ee53be21482">
window.__oai_logHTML ? window.__oai_logHTML() : window.__oai_SSR_HTML = window.__oai_SSR_HTML || Date.now();
requestAnimationFrame((function() {
window.__oai_logTTI ? window.__oai_logTTI() : window.__oai_SSR_TTI = window.__oai_SSR_TTI || Date.now()
Expand Down Expand Up @@ -228,7 +231,7 @@ <h1 class="result-streaming absolute left-full transition-opacity" style="opacit
<div aria-live="assertive" aria-atomic="true" class="sr-only"></div>
<div aria-live="polite" aria-atomic="true" class="sr-only"></div>
<audio class="fixed bottom-0 left-0 hidden h-0 w-0" autoPlay="" crossorigin="anonymous"></audio>
<script nonce="e92906e6-e5fd-444f-803b-dd857bdafea6">
<script nonce="cdf9b650-861c-444c-b543-6ee53be21482">
window.__remixContext = {{ remix_context|tojson }};
__remixContext.p = function(v, e, p, x) {
if (typeof e !== 'undefined') {
Expand Down Expand Up @@ -277,12 +280,16 @@ <h1 class="result-streaming absolute left-full transition-opacity" style="opacit
}
}
;
Object.assign(__remixContext.state.loaderData["root"], {
"rq:[\"account-status\"]": __remixContext.n("root", "rq:[\"account-status\"]")
});
Object.assign(__remixContext.state.loaderData["routes/_conversation"], {});
__remixContext.a = 1;
</script>
<script nonce="e92906e6-e5fd-444f-803b-dd857bdafea6" type="module" async="">
import "/assets/manifest-02df4098.js";
import*as route0 from "/assets/bf2p2f1vepq4y3f7.js";
import*as route1 from "/assets/nklvdpoxrgpd3hmb.js";
<script nonce="cdf9b650-861c-444c-b543-6ee53be21482" type="module" async="">
import "/assets/manifest-a231f861.js";
import*as route0 from "/assets/jbzdfqf5ym1dx59x.js";
import*as route1 from "/assets/mwj83gxumd1zqfgp.js";
import*as route2 from "/assets/jjr9on9cxlrbskjq.js";

window.__remixRouteModules = {
Expand All @@ -291,7 +298,89 @@ <h1 class="result-streaming absolute left-full transition-opacity" style="opacit
"routes/_conversation._index": route2
};

import("/assets/e5bysna0b8zobmag.js");
import("/assets/d6whfiv7obppelxo.js");
</script>
<!--$?-->
<template id="B:0"></template>
<!--/$-->
<div hidden id="S:0">
<script nonce="cdf9b650-861c-444c-b543-6ee53be21482" async="">
__remixContext.r("root", "rq:[\"account-status\"]", {
"__type": "AccountState",
"accountItems": [{
"data": {
"id": "71e70fbb-101e-4345-835d-a587e597d407",
"residencyRegion": "no_constraint",
"accountUserId": "user-XvlBB0N9L5u7pkJJCckjTzVm__71e70fbb-101e-4345-835d-a587e597d407",
"name": null,
"profilePictureId": null,
"profilePictureUrl": null,
"structure": "personal",
"role": "account-owner",
"organizationId": null,
"promoData": {},
"deactivated": false,
"subscriptionStatus": {
"billingPeriod": null,
"hasPaidSubscription": false,
"subscriptionPlan": "chatgptfreeplan",
"planType": "free",
"wasPaidCustomer": false,
"hasCustomerObject": false,
"lastActiveSubscription": {
"subscription_id": null,
"purchase_origin_platform": "chatgpt_not_purchased",
"will_renew": false
},
"isResellerHosted": false
},
"features": ["bizmo_settings", "breeze_available", "canvas", "chat_preferences_available", "chatgpt_ios_attest", "chatgpt_team_plan", "d3_controls", "d3_editor_gpts", "gizmo_interact_unpaid", "gizmo_reviews", "gizmo_support_emails", "invite_referral", "mfa", "model_ab_use_v2", "new_plugin_oauth_endpoint", "no_auth_training_enabled_by_default", "paragen_mainline_alternative", "privacy_policy_nov_2023", "sentinel_enabled_for_subscription", "share_multimodal_links", "shareable_links", "starter_prompts", "sunshine_available", "user_settings_announcements", "voice_advanced_ga"],
"canAccessWithCurrentSession": true,
"ssoConnectionName": null
}
}],
"currentAccountId": "71e70fbb-101e-4345-835d-a587e597d407"
})
</script>
</div>
<script nonce="cdf9b650-861c-444c-b543-6ee53be21482">
$RC = function(b, c, e) {
c = document.getElementById(c);
c.parentNode.removeChild(c);
var a = document.getElementById(b);
if (a) {
b = a.previousSibling;
if (e)
b.data = "$!",
a.setAttribute("data-dgst", e);
else {
e = b.parentNode;
a = b.nextSibling;
var f = 0;
do {
if (a && 8 === a.nodeType) {
var d = a.data;
if ("/$" === d)
if (0 === f)
break;
else
f--;
else
"$" !== d && "$?" !== d && "$!" !== d || f++
}
d = a.nextSibling;
e.removeChild(a);
a = d
} while (a);
for (; c.firstChild; )
e.insertBefore(c.firstChild, a);
b.data = "$"
}
b._reactRetry && b._reactRetry()
}
}
;
$RC("B:0", "S:0")
</script>
</body>
</html>
Loading

0 comments on commit 8e7acbd

Please sign in to comment.