summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/Theb.py
diff options
context:
space:
mode:
authorAndPim4912 <52836885+AndPim4912@users.noreply.github.com>2023-10-23 14:10:28 +0200
committerGitHub <noreply@github.com>2023-10-23 14:10:28 +0200
commit8d7ad98fcb314453c01f6dcd4bfe59016efd78ce (patch)
tree4d39804e1aa1724560e1688f0b6d4c124b9771c7 /g4f/Provider/needs_auth/Theb.py
parentRefactor API initialization to accept a list of ignored providers. (diff)
parentDebug config in api (diff)
downloadgpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.gz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.bz2
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.lz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.xz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.zst
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.zip
Diffstat (limited to 'g4f/Provider/needs_auth/Theb.py')
-rw-r--r--g4f/Provider/needs_auth/Theb.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/g4f/Provider/needs_auth/Theb.py b/g4f/Provider/needs_auth/Theb.py
index 9803db97..b3c9019d 100644
--- a/g4f/Provider/needs_auth/Theb.py
+++ b/g4f/Provider/needs_auth/Theb.py
@@ -28,28 +28,28 @@ class Theb(BaseProvider):
"bearer_token":"free",
"org_id":"theb",
})
-
+
bearer_token = auth["bearer_token"]
org_id = auth["org_id"]
-
+
headers = {
- 'authority' : 'beta.theb.ai',
- 'accept' : 'text/event-stream',
- 'accept-language' : 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
- 'authorization' : 'Bearer '+bearer_token,
- 'content-type' : 'application/json',
- 'origin' : 'https://beta.theb.ai',
- 'referer' : 'https://beta.theb.ai/home',
- 'sec-ch-ua' : '"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
- 'sec-ch-ua-mobile' : '?0',
+ 'authority': 'beta.theb.ai',
+ 'accept': 'text/event-stream',
+ 'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
+ 'authorization': f'Bearer {bearer_token}',
+ 'content-type': 'application/json',
+ 'origin': 'https://beta.theb.ai',
+ 'referer': 'https://beta.theb.ai/home',
+ 'sec-ch-ua': '"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
+ 'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
- 'sec-fetch-dest' : 'empty',
- 'sec-fetch-mode' : 'cors',
- 'sec-fetch-site' : 'same-origin',
- 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
- 'x-ai-model' : 'ee8d4f29cb7047f78cbe84313ed6ace8',
+ 'sec-fetch-dest': 'empty',
+ 'sec-fetch-mode': 'cors',
+ 'sec-fetch-site': 'same-origin',
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
+ 'x-ai-model': 'ee8d4f29cb7047f78cbe84313ed6ace8',
}
-
+
req_rand = random.randint(100000000, 9999999999)
json_data: dict[str, Any] = {
@@ -65,7 +65,7 @@ class Theb(BaseProvider):
"long_term_memory" : "auto"
}
}
-
+
response = requests.post(
f"https://beta.theb.ai/api/conversation?org_id={org_id}&req_rand={req_rand}",
headers=headers,
@@ -73,7 +73,7 @@ class Theb(BaseProvider):
stream=True,
proxies={"https": proxy}
)
-
+
response.raise_for_status()
content = ""
next_content = ""
@@ -82,7 +82,7 @@ class Theb(BaseProvider):
next_content = content
data = json.loads(chunk.decode().split("data: ")[1])
content = data["content"]
- yield data["content"].replace(next_content, "")
+ yield content.replace(next_content, "")
@classmethod
@property