From 67d00acb0cd35d0f1bc774b7684462645a38df6a Mon Sep 17 00:00:00 2001 From: lanqian528 <5499636+lanqian528@users.noreply.github.com> Date: Sat, 17 May 2025 17:57:34 +0800 Subject: [PATCH] v1.9.1-beta1 fix bugs --- chatgpt/ChatService.py | 18 +- chatgpt/chatFormat.py | 3 + chatgpt/refreshToken.py | 10 +- templates/chatgpt.html | 487 +- templates/chatgpt_context_1.json | 6700 ++++++++++++----------- templates/chatgpt_context_2.json | 193 +- templates/gpts_context.json | 8811 ++++++++++++++++-------------- utils/Client.py | 2 +- 8 files changed, 8573 insertions(+), 7651 deletions(-) diff --git a/chatgpt/ChatService.py b/chatgpt/ChatService.py index a75a71c..edaf0f1 100644 --- a/chatgpt/ChatService.py +++ b/chatgpt/ChatService.py @@ -189,7 +189,7 @@ class ChatService: config = get_config(self.user_agent, self.req_token) p = get_requirements_token(config) data = {'p': p} - r = await self.ss.post(url, headers=headers, json=data, timeout=5) + r = await self.ss.post(url, headers=headers, json=data, timeout=10) if r.status_code == 200: resp = r.json() @@ -319,35 +319,33 @@ class ChatService: "time_since_loaded": random.randint(50, 500), "page_height": random.randint(500, 1000), "page_width": random.randint(1000, 2000), - "pixel_ratio": 1.5, - "screen_height": random.randint(800, 1200), - "screen_width": random.randint(1200, 2200), + "pixel_ratio": 1, + "screen_height": 1440, + "screen_width": 2560, }, "conversation_mode": conversation_mode, - "conversation_origin": None, + "enable_message_followups": False, "force_paragen": False, "force_paragen_model_slug": "", "force_rate_limit": False, "force_use_sse": True, - "history_and_training_disabled": self.history_disabled, "messages": chat_messages, "model": self.req_model, "paragen_cot_summary_display_override": "allow", - "paragen_stream_type_override": None, "parent_message_id": self.parent_message_id if self.parent_message_id else f"client-created-root", - "reset_rate_limits": False, - "suggestions": [], "supported_encodings": ["v1"], "system_hints": [], "timezone": "America/Los_Angeles", "timezone_offset_min": -480, "variant_purpose": "comparison_implicit", - "websocket_request_id": f"{uuid.uuid4()}", } if "image" in self.origin_model or "image" in self.req_model: self.chat_request["system_hints"].append("picture_v2") if self.conversation_id: self.chat_request['conversation_id'] = self.conversation_id + if self.history_disabled: + self.chat_request["history_and_training_disabled"] = True + return self.chat_request async def send_conversation(self): diff --git a/chatgpt/chatFormat.py b/chatgpt/chatFormat.py index fb60e12..c93f237 100644 --- a/chatgpt/chatFormat.py +++ b/chatgpt/chatFormat.py @@ -467,6 +467,9 @@ async def api_messages_to_chat(service, api_messages, upload_by_url=False): "metadata": metadata } chat_messages.append(chat_message) + if "image" in service.origin_model or "image" in service.req_model: + chat_messages[-1]["metadata"]["system_hints"] = ["picture_v2"] + text_tokens = await num_tokens_from_messages(api_messages, service.resp_model) prompt_tokens = text_tokens + file_tokens return chat_messages, prompt_tokens diff --git a/chatgpt/refreshToken.py b/chatgpt/refreshToken.py index a580a75..4002d87 100644 --- a/chatgpt/refreshToken.py +++ b/chatgpt/refreshToken.py @@ -35,11 +35,19 @@ async def chat_refresh(refresh_token): "redirect_uri": "com.openai.chat://auth0.openai.com/ios/com.openai.chat/callback", "refresh_token": refresh_token } + headers = { + 'accept': '*/*', + 'accept-encoding': 'gzip, deflate, br, zstd', + 'accept-language': 'en-US,en;q=0.9', + 'content-type': 'application/json', + 'origin': 'https://auth0.openai.com', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0' + } session_id = hashlib.md5(refresh_token.encode()).hexdigest() proxy_url = random.choice(proxy_url_list).replace("{}", session_id) if proxy_url_list else None client = Client(proxy=proxy_url) try: - r = await client.post("https://auth0.openai.com/oauth/token", json=data, timeout=15) + r = await client.post("https://auth0.openai.com/oauth/token", json=data, headers=headers, timeout=15) if r.status_code == 200: access_token = r.json()['access_token'] return access_token diff --git a/templates/chatgpt.html b/templates/chatgpt.html index fe904a3..f5ab1f4 100644 --- a/templates/chatgpt.html +++ b/templates/chatgpt.html @@ -1,52 +1,52 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ChatGPT @@ -59,16 +59,17 @@ - - + + {% raw %} - + {% endraw %} - - - -{{ clear_localstorage_script | safe }} + {{ clear_localstorage_script | safe }} - Skip to content + 跳至内容
-
-
-
-
-
-
-

Chat history

- -
-
-
-
-
+
+
+