diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-11-21 07:14:36 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-11-21 07:14:36 +0100 |
commit | 6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419 (patch) | |
tree | 2c5a647a67c8f0b208a21e1bde4f4943980e1c36 /g4f/Provider | |
parent | Support synthesize in Openai generator (#2394) (diff) | |
download | gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.tar gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.tar.gz gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.tar.bz2 gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.tar.lz gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.tar.xz gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.tar.zst gpt4free-6f2b6cccbda6b3cd7ec5e0d5ba8ebf23d7c53419.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/needs_auth/OpenaiChat.py | 4 | ||||
-rw-r--r-- | g4f/Provider/openai/har_file.py | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py index 797455fe..29e3d4b4 100644 --- a/g4f/Provider/needs_auth/OpenaiChat.py +++ b/g4f/Provider/needs_auth/OpenaiChat.py @@ -418,6 +418,7 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin): [debug.log(text) for text in ( f"Arkose: {'False' if not need_arkose else RequestConfig.arkose_token[:12]+'...'}", f"Proofofwork: {'False' if proofofwork is None else proofofwork[:12]+'...'}", + f"AccessToken: {'False' if cls._api_key is None else cls._api_key[:12]+'...'}", )] data = { "action": action, @@ -438,7 +439,8 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin): messages = messages if conversation_id is None else [messages[-1]] data["messages"] = cls.create_messages(messages, image_request) headers = { - "accept": "text/event-stream", + "Accept": "text/event-stream", + "Content-Type": "application/json", "Openai-Sentinel-Chat-Requirements-Token": chat_token, **cls._headers } diff --git a/g4f/Provider/openai/har_file.py b/g4f/Provider/openai/har_file.py index 4569e1b7..d731bf73 100644 --- a/g4f/Provider/openai/har_file.py +++ b/g4f/Provider/openai/har_file.py @@ -81,10 +81,10 @@ def readHAR(): RequestConfig.access_token = match.group(1) except KeyError: continue - RequestConfig.cookies = {c['name']: c['value'] for c in v['request']['cookies'] if c['name'] != "oai-did"} + RequestConfig.cookies = {c['name']: c['value'] for c in v['request']['cookies']} RequestConfig.headers = v_headers - if RequestConfig.access_token is None: - raise NoValidHarFileError("No accessToken found in .har files") + if RequestConfig.proof_token is None: + raise NoValidHarFileError("No proof_token found in .har files") def get_headers(entry) -> dict: return {h['name'].lower(): h['value'] for h in entry['request']['headers'] if h['name'].lower() not in ['content-length', 'cookie'] and not h['name'].startswith(':')} @@ -149,7 +149,7 @@ def getN() -> str: return base64.b64encode(timestamp.encode()).decode() async def get_request_config(proxy: str) -> RequestConfig: - if RequestConfig.access_token is None: + if RequestConfig.proof_token is None: readHAR() if RequestConfig.arkose_request is not None: RequestConfig.arkose_token = await sendRequest(genArkReq(RequestConfig.arkose_request), proxy) |