mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
update gpt-4o
This commit is contained in:
parent
7780e9ebe4
commit
d0aba83db3
@ -6,6 +6,7 @@ model_proxy = {
|
||||
"gpt-4-turbo-preview": "gpt-4-0125-preview",
|
||||
"gpt-4-vision-preview": "gpt-4-1106-vision-preview",
|
||||
"gpt-4-turbo": "gpt-4-turbo-2024-04-09",
|
||||
"gpt-4o": "gpt-4o-2024-05-13",
|
||||
"claude-3-opus": "claude-3-opus-20240229",
|
||||
"claude-3-sonnet": "claude-3-sonnet-20240229",
|
||||
"claude-3-haiku": "claude-3-haiku-20240307",
|
||||
@ -18,5 +19,6 @@ model_system_fingerprint = {
|
||||
"fp_b77cb481ed"],
|
||||
"gpt-4-1106-preview": ["fp_e467c31c3d", "fp_d986a8d1ba", "fp_99a5a401bb", "fp_123d5a9f90", "fp_0d1affc7a6",
|
||||
"fp_5c95a4634e"],
|
||||
"gpt-4-turbo-2024-04-09": ["fp_d1bac968b4"]
|
||||
"gpt-4-turbo-2024-04-09": ["fp_d1bac968b4"],
|
||||
"gpt-4o-2024-05-13": ["fp_d1bac968b4"]
|
||||
}
|
||||
|
||||
@ -96,12 +96,13 @@ class ChatService:
|
||||
resp = r.json()
|
||||
self.persona = resp.get("persona")
|
||||
if "gpt-4" in self.origin_model and self.persona != "chatgpt-paid":
|
||||
raise HTTPException(status_code=404, detail={
|
||||
"message": f"The model `{self.origin_model}` does not exist or you do not have access to it.",
|
||||
"type": "invalid_request_error",
|
||||
"param": None,
|
||||
"code": "model_not_found"
|
||||
})
|
||||
if "gpt-4o" not in self.origin_model:
|
||||
raise HTTPException(status_code=404, detail={
|
||||
"message": f"The model `{self.origin_model}` does not exist or you do not have access to it.",
|
||||
"type": "invalid_request_error",
|
||||
"param": None,
|
||||
"code": "model_not_found"
|
||||
})
|
||||
arkose = resp.get('arkose', {})
|
||||
proofofwork = resp.get('proofofwork', {})
|
||||
turnstile = resp.get('turnstile', {})
|
||||
@ -166,19 +167,19 @@ class ChatService:
|
||||
'Openai-Sentinel-Proof-Token': self.proof_token,
|
||||
'Openai-Sentinel-Arkose-Token': self.arkose_token,
|
||||
})
|
||||
conversation_mode = {"kind": "primary_assistant"}
|
||||
if "gizmo" in self.origin_model:
|
||||
model = "gpt-4"
|
||||
gizmo_id = self.data.get("model").split("gpt-4-gizmo-")[-1]
|
||||
conversation_mode = {"kind": "gizmo_interaction", "gizmo_id": gizmo_id}
|
||||
elif "gpt-4-mobile" in self.origin_model:
|
||||
model = "gpt-4-mobile"
|
||||
conversation_mode = {"kind": "primary_assistant"}
|
||||
elif "gpt-4o" in self.origin_model:
|
||||
model = "gpt-4o"
|
||||
elif "gpt-4" in self.origin_model:
|
||||
model = "gpt-4"
|
||||
conversation_mode = {"kind": "primary_assistant"}
|
||||
else:
|
||||
model = "text-davinci-002-render-sha"
|
||||
conversation_mode = {"kind": "primary_assistant"}
|
||||
logger.info(f"Model mapping: {self.origin_model} -> {model}")
|
||||
self.chat_request = {
|
||||
"action": "next",
|
||||
|
||||
@ -105,7 +105,9 @@ async def chatgpt_reverse_proxy(request: Request, path: str):
|
||||
try:
|
||||
r = await client.request(request.method, f"{base_url}/{path}", params=params, headers=headers,
|
||||
cookies=request_cookies, data=data, stream=True, allow_redirects=False)
|
||||
if r.status_code == 307:
|
||||
if r.status_code == 304:
|
||||
return Response(status_code=304)
|
||||
elif r.status_code == 307:
|
||||
if "oai-dm=1" not in r.headers.get("Location"):
|
||||
return Response(status_code=307, headers={
|
||||
"Location": r.headers.get("Location").replace("chat.openai.com", origin_host)
|
||||
@ -135,7 +137,7 @@ async def chatgpt_reverse_proxy(request: Request, path: str):
|
||||
for cookie_name in r.cookies:
|
||||
if cookie_name in request_cookies:
|
||||
continue
|
||||
for cookie_domain in [".chatgpt.com", ".chat.openai.com"]:
|
||||
for cookie_domain in [".chatgpt.com"]:
|
||||
cookie_value = r.cookies.get(name=cookie_name, domain=cookie_domain)
|
||||
if cookie_name.startswith("__"):
|
||||
response.set_cookie(key=cookie_name, value=cookie_value, secure=True, httponly=True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user