summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/openai/har_file.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-05 21:03:12 +0200
committerGitHub <noreply@github.com>2024-04-05 21:03:12 +0200
commitc791012b218667e1449e1224014f05213fb1fc9c (patch)
treeb4ab92cd92c386b86cdeea1b4d80d3eec43eb02f /g4f/Provider/openai/har_file.py
parentFix Gemini Proxy Connect call failed (#1768) (diff)
parentAdd authless OpenaiChat (diff)
downloadgpt4free-0.2.8.0.tar
gpt4free-0.2.8.0.tar.gz
gpt4free-0.2.8.0.tar.bz2
gpt4free-0.2.8.0.tar.lz
gpt4free-0.2.8.0.tar.xz
gpt4free-0.2.8.0.tar.zst
gpt4free-0.2.8.0.zip
Diffstat (limited to 'g4f/Provider/openai/har_file.py')
-rw-r--r--g4f/Provider/openai/har_file.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/g4f/Provider/openai/har_file.py b/g4f/Provider/openai/har_file.py
index 68fe7420..8936c131 100644
--- a/g4f/Provider/openai/har_file.py
+++ b/g4f/Provider/openai/har_file.py
@@ -11,6 +11,9 @@ from copy import deepcopy
from .crypt import decrypt, encrypt
from ...requests import StreamSession
+class NoValidHarFileError(Exception):
+ ...
+
class arkReq:
def __init__(self, arkURL, arkBx, arkHeader, arkBody, arkCookies, userAgent):
self.arkURL = arkURL
@@ -39,7 +42,7 @@ def readHAR():
if harPath:
break
if not harPath:
- raise RuntimeError("No .har file found")
+ raise NoValidHarFileError("No .har file found")
for path in harPath:
with open(path, 'rb') as file:
try:
@@ -54,7 +57,7 @@ def readHAR():
accessToken = json.loads(v["response"]["content"]["text"]).get("accessToken")
cookies = {c['name']: c['value'] for c in v['request']['cookies']}
if not accessToken:
- RuntimeError("No accessToken found in .har files")
+ raise NoValidHarFileError("No accessToken found in .har files")
if not chatArks:
return None, accessToken, cookies
return chatArks.pop(), accessToken, cookies
@@ -75,9 +78,6 @@ def parseHAREntry(entry) -> arkReq:
return tmpArk
def genArkReq(chatArk: arkReq) -> arkReq:
- if not chatArk:
- raise RuntimeError("No .har file with arkose found")
-
tmpArk: arkReq = deepcopy(chatArk)
if tmpArk is None or not tmpArk.arkBody or not tmpArk.arkHeader:
raise RuntimeError("The .har file is not valid")