v1.6.10-beta2 support gpts

This commit is contained in:
lanqian528 2024-11-05 16:21:48 +08:00
parent 27f88ca49f
commit e1aa87f2fa
5 changed files with 7295 additions and 990 deletions

View File

@ -10,8 +10,24 @@ from app import app, templates
from gateway.reverseProxy import chatgpt_reverse_proxy
from utils.configs import enable_gateway
with open("templates/remix_context.json", "r", encoding="utf-8") as f:
remix_context = json.load(f)
with open("templates/chatgpt_context.json", "r", encoding="utf-8") as f:
chatgpt_context = json.load(f)
with open("templates/gpts_context.json", "r", encoding="utf-8") as f:
gpts_context = json.load(f)
banned_paths = [
"backend-api/accounts/logout_all",
"backend-api/accounts/deactivate",
"backend-api/user_system_messages",
"backend-api/memories",
"backend-api/settings/clear_account_user_memory",
"backend-api/conversations/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
"backend-api/accounts/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/invites",
"admin",
]
redirect_paths = ["auth/logout"]
chatgpt_paths = ["c/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"]
def set_value_for_key(data, target_key, new_value):
@ -35,7 +51,7 @@ if enable_gateway:
if not token:
return await login_html(request)
user_remix_context = remix_context.copy()
user_remix_context = chatgpt_context.copy()
set_value_for_key(user_remix_context, "user", {"id": "user-chatgpt"})
set_value_for_key(user_remix_context, "accessToken", token)
@ -71,6 +87,14 @@ if enable_gateway:
async def get_gpts():
return {"kind": "store"}
@app.get("/g/g-{gizmo_id}")
async def get_gizmo_json(request: Request, gizmo_id: str):
params = request.query_params
if params.get("_data") == "routes/g.$gizmoId._index":
return Response(content=json.dumps(gpts_context, indent=4), media_type="application/json")
else:
return await chatgpt_html(request)
@app.get("/backend-api/gizmos/bootstrap")
async def get_gizmos_bootstrap():
@ -129,8 +153,7 @@ if enable_gateway:
return patch_response
else:
data = await request.json()
if conversation_id in globals.seed_map[token][
"conversations"] and conversation_id in globals.conversation_map:
if conversation_id in globals.seed_map[token]["conversations"] and conversation_id in globals.conversation_map:
if not data.get("is_visible", True):
globals.conversation_map.pop(conversation_id)
globals.seed_map[token]["conversations"].remove(conversation_id)
@ -143,6 +166,16 @@ if enable_gateway:
return patch_response
@app.post("/v1/initialize")
async def initialize(request: Request):
initialize_response = (await chatgpt_reverse_proxy(request, f"/v1/initialize"))
initialize_str = initialize_response.body.decode('utf-8')
initialize_json = json.loads(initialize_str)
set_value_for_key(initialize_json, "ip", "8.8.8.8")
set_value_for_key(initialize_json, "country", "US")
return Response(content=json.dumps(initialize_json, indent=4), media_type="application/json")
@app.get("/backend-api/me")
async def get_me(request: Request):
me = {
@ -191,20 +224,6 @@ if enable_gateway:
return me
banned_paths = [
"backend-api/accounts/logout_all",
"backend-api/accounts/deactivate",
"backend-api/user_system_messages",
"backend-api/memories",
"backend-api/settings/clear_account_user_memory",
"backend-api/conversations/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
"backend-api/accounts/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/invites",
"admin",
]
redirect_paths = ["auth/logout"]
chatgpt_paths = ["c/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"]
@app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"])
async def reverse_proxy(request: Request, path: str):
if re.match("/v1/rgstr", path):

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html data-build="prod-bf34a49b1a069459615ed830ce45441d6b9a54ee" dir="ltr" class="">
<html data-build="prod-ecc0207d57b2a1317adeee3f3b5e693f287547aa" dir="ltr" class="">
<head>
<meta charSet="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
@ -18,55 +18,54 @@
<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-3ade92e0.js"/>
<link rel="modulepreload" href="/assets/d9z3tlgc2shput1x.js"/>
<link rel="modulepreload" href="/assets/jipkz7wahhvzzuqx.js"/>
<link rel="modulepreload" href="/assets/36ro7pf3i6oxqv6i.js"/>
<link rel="modulepreload" href="/assets/n5nz8vnsxibd6bik.js"/>
<link rel="modulepreload" href="/assets/mdo2ehpmzqbbrcw9.js"/>
<link rel="modulepreload" href="/assets/bvxb7ko3h6ykpbi0.js"/>
<link rel="modulepreload" href="/assets/e6zhtx99a7i1g9zc.js"/>
<link rel="modulepreload" href="/assets/npl77qwfuvi2jyha.js"/>
<link rel="modulepreload" href="/assets/fwm14uzkyzsxflxc.js"/>
<link rel="modulepreload" href="/assets/lbv1zpv4g2ap41f2.js"/>
<link rel="modulepreload" href="/assets/hu4ya3hu1q2mtj3c.js"/>
<link rel="modulepreload" href="/assets/fqai4h0y4a7y6yiz.js"/>
<link rel="modulepreload" href="/assets/kgz011geyku0c84g.js"/>
<link rel="modulepreload" href="/assets/lb2bw82esu8k4ire.js"/>
<link rel="modulepreload" href="/assets/j625ckqact10y3my.js"/>
<link rel="modulepreload" href="/assets/it892upc0b17konk.js"/>
<link rel="modulepreload" href="/assets/ojtyfghvwqol77ni.js"/>
<link rel="modulepreload" href="/assets/gf1rzma6lb3hhiaa.js"/>
<link rel="modulepreload" href="/assets/n7shmditr84egzzk.js"/>
<link rel="modulepreload" href="/assets/ncnmvo4fatoh9z2b.js"/>
<link rel="modulepreload" href="/assets/efad9c3t7hoskfux.js"/>
<link rel="modulepreload" href="/assets/erjy4zyeqfne1prk.js"/>
<link rel="modulepreload" href="/assets/i21elbjdr0dt7siq.js"/>
<link rel="modulepreload" href="/assets/nh5giofbgo8o5iz3.js"/>
<link rel="modulepreload" href="/assets/hz1kryv1rsw2w11f.js"/>
<link rel="modulepreload" href="/assets/m02oxzinki55f1a4.js"/>
<link rel="modulepreload" href="/assets/c78o8wyvzedeoudw.js"/>
<link rel="modulepreload" href="/assets/gecwa6udk6b6d8e5.js"/>
<link rel="modulepreload" href="/assets/g70459ispqthxwkc.js"/>
<link rel="modulepreload" href="/assets/kl3gqai6eyrksb78.js"/>
<link rel="modulepreload" href="/assets/l6n2tuza1m4x9jmr.js"/>
<link rel="modulepreload" href="/assets/jwoa39qbou2pb90k.js"/>
<link rel="modulepreload" href="/assets/lxkd2uemxq651aut.js"/>
<link rel="modulepreload" href="/assets/f2w9prfaqv5jn6b6.js"/>
<link rel="modulepreload" href="/assets/dp98tj9u73hn9ufz.js"/>
<link rel="modulepreload" href="/assets/k5lnvw1mrt1nlhku.js"/>
<link rel="modulepreload" href="/assets/nsw6odx5xh6i9cc3.js"/>
<link rel="modulepreload" href="/assets/dp2xls1tq8hl6hdd.js"/>
<link rel="modulepreload" href="/assets/o8ne9dgj82ugno4a.js"/>
<link rel="modulepreload" href="/assets/hpwzwf5t45kgizxl.js"/>
<link rel="modulepreload" href="/assets/fcr06eqoxz5nj0zr.js"/>
<link rel="modulepreload" href="/assets/cyzxbqfgo2fnhaph.js"/>
<link rel="modulepreload" href="/assets/f1ccpn6bozgd3iqc.js"/>
<link rel="modulepreload" href="/assets/m5dixe5n71jzyt0l.js"/>
<link rel="modulepreload" href="/assets/ifx68p1cwmj10rjy.js"/>
<link rel="modulepreload" href="/assets/koa1s917opmrb6zb.js"/>
<link rel="modulepreload" href="/assets/manifest-317e0442.js"/>
<link rel="modulepreload" href="/assets/l0flmalf4tyvsm1b.js"/>
<link rel="modulepreload" href="/assets/cenhwbprxai3toix.js"/>
<link rel="modulepreload" href="/assets/mej6dcn3epzdp940.js"/>
<link rel="modulepreload" href="/assets/lzqwtbp50roqvxnh.js"/>
<link rel="modulepreload" href="/assets/esp1o2lmeinam0sh.js"/>
<link rel="modulepreload" href="/assets/wg6ecvahwsvfbs7t.js"/>
<link rel="modulepreload" href="/assets/bomvf441parvbl6l.js"/>
<link rel="modulepreload" href="/assets/jyh9xl3syf7yrebg.js"/>
<link rel="modulepreload" href="/assets/jth9gz8y4nfsu03x.js"/>
<link rel="modulepreload" href="/assets/h0w2cfyxquh3a88t.js"/>
<link rel="modulepreload" href="/assets/i2mam4exf28ww00h.js"/>
<link rel="modulepreload" href="/assets/kp41qb109q7zsu08.js"/>
<link rel="modulepreload" href="/assets/e3lzzvpbrfw34hi0.js"/>
<link rel="modulepreload" href="/assets/s26g8cj5crlmzrhm.js"/>
<link rel="modulepreload" href="/assets/cd7rmveqys68yu6w.js"/>
<link rel="modulepreload" href="/assets/hn586u5on2jlex6e.js"/>
<link rel="modulepreload" href="/assets/hn877s1av7risab0.js"/>
<link rel="modulepreload" href="/assets/c657bb6sfxb67al1.js"/>
<link rel="modulepreload" href="/assets/i5dl7qcorvwptxtt.js"/>
<link rel="modulepreload" href="/assets/j72yt11gyo474tkr.js"/>
<link rel="modulepreload" href="/assets/d01hwntyf2775ji3.js"/>
<link rel="modulepreload" href="/assets/kcdclgxeuzpy449e.js"/>
<link rel="modulepreload" href="/assets/bh0hpeydruybhwyo.js"/>
<link rel="modulepreload" href="/assets/ghlhzub07tt8683j.js"/>
<link rel="modulepreload" href="/assets/er1c9qkbvqkr07px.js"/>
<link rel="modulepreload" href="/assets/f994slaknt0q0gbk.js"/>
<link rel="modulepreload" href="/assets/id6ryfq9914uxpp5.js"/>
<link rel="modulepreload" href="/assets/oc6674sla3qapg4k.js"/>
<link rel="modulepreload" href="/assets/olbio5uf8m7nh5z5.js"/>
<link rel="modulepreload" href="/assets/if0s6lpo3mwf7mho.js"/>
<link rel="modulepreload" href="/assets/jmi851zx6qdtjhdj.js"/>
<link rel="modulepreload" href="/assets/i51i3k321hvaxal9.js"/>
<link rel="modulepreload" href="/assets/lfvhb0nf0ozjlpqm.js"/>
<link rel="modulepreload" href="/assets/lwsvc0prcm5qybau.js"/>
<link rel="modulepreload" href="/assets/dmau43v1lisg5o8k.js"/>
<link rel="modulepreload" href="/assets/leqgnttd8q44vj5y.js"/>
<link rel="modulepreload" href="/assets/opnnku3lurllu7tw.js"/>
<link rel="modulepreload" href="/assets/bj8mbuhov5xcqf0f.js"/>
<link rel="modulepreload" href="/assets/kehs2ll784eynnt2.js"/>
<link rel="modulepreload" href="/assets/fxwpnfsczjkyx99q.js"/>
<link rel="modulepreload" href="/assets/cw70vbnpved29h73.js"/>
<link rel="modulepreload" href="/assets/hibtdcbfc20dw1xa.js"/>
<link rel="modulepreload" href="/assets/jrixumr7y4kpqw3k.js"/>
<link rel="modulepreload" href="/assets/lrh8wz5t6uhmx4c9.js"/>
<link rel="modulepreload" href="/assets/fnze8ev0ssatnf92.js"/>
<link rel="modulepreload" href="/assets/jjr9on9cxlrbskjq.js"/>
<link rel="stylesheet" href="/assets/root-fm8m2265.css"/>
<link rel="stylesheet" href="/assets/root-o2r7uhf3.css"/>
<link rel="stylesheet" href="/assets/conversation-small-cll5buey.css"/>
</head>
<body class="">
@ -96,7 +95,7 @@
}()
</script>
<div class="relative flex h-full w-full overflow-hidden transition-colors z-0">
<div class="z-[1] flex-shrink-0 overflow-x-hidden bg-token-sidebar-surface-primary max-md:!w-0" style="width:260px">
<div class="z-[21] flex-shrink-0 overflow-x-hidden bg-token-sidebar-surface-primary max-md:!w-0" style="width:260px">
<div class="h-full w-[260px]">
<div class="flex h-full min-h-0 flex-col">
<div class="draggable relative h-full w-full flex-1 items-start border-white/20">
@ -194,7 +193,7 @@
</div>
</div>
<div class="w-full">
<form class="w-full" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="radix-:Rpn99iii4lj5:" data-state="closed">
<form class="w-full" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="radix-:Rdf99iii4lj5:" 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">
@ -203,7 +202,7 @@
<div class="flex min-w-0 flex-1 flex-col">
<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="2887053f-167d-4b8d-b616-8ea78c3e74b7">
<script nonce="c5a3ef22-c71c-4ae3-9939-b19d1edaee92">
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()
@ -257,7 +256,7 @@
<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="2887053f-167d-4b8d-b616-8ea78c3e74b7">
<script nonce="c5a3ef22-c71c-4ae3-9939-b19d1edaee92">
window.__remixContext = {{ remix_context|tojson }};
__remixContext.p = function(v, e, p, x) {
if (typeof e !== 'undefined') {
@ -312,10 +311,10 @@
Object.assign(__remixContext.state.loaderData["routes/_conversation"], {});
__remixContext.a = 1;
</script>
<script nonce="2887053f-167d-4b8d-b616-8ea78c3e74b7" type="module" async="">
import "/assets/manifest-3ade92e0.js";
import*as route0 from "/assets/mdo2ehpmzqbbrcw9.js";
import*as route1 from "/assets/koa1s917opmrb6zb.js";
<script nonce="c5a3ef22-c71c-4ae3-9939-b19d1edaee92" type="module" async="">
import "/assets/manifest-317e0442.js";
import*as route0 from "/assets/esp1o2lmeinam0sh.js";
import*as route1 from "/assets/fnze8ev0ssatnf92.js";
import*as route2 from "/assets/jjr9on9cxlrbskjq.js";
window.__remixRouteModules = {
@ -324,7 +323,46 @@
"routes/_conversation._index": route2
};
import("/assets/d9z3tlgc2shput1x.js");
import("/assets/l0flmalf4tyvsm1b.js");
</script>
<script nonce="c5a3ef22-c71c-4ae3-9939-b19d1edaee92">
$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>

File diff suppressed because it is too large Load Diff

5510
templates/gpts_context.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
1.6.10-beta1
1.6.10-beta2