summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/Theb.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-10 00:18:17 +0200
committerGitHub <noreply@github.com>2023-10-10 00:18:17 +0200
commit8a5c23f693c1ad92b5d5259201bb99807f76ea2a (patch)
tree26a25d7b5bee6ba1e2ac484e1ad124a8e52b0b43 /g4f/Provider/needs_auth/Theb.py
parentMerge branch 'main' of https://github.com/xtekky/gpt4free (diff)
parent Add Proxy Support and Create Provider to Readme (diff)
downloadgpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.tar
gpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.tar.gz
gpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.tar.bz2
gpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.tar.lz
gpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.tar.xz
gpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.tar.zst
gpt4free-8a5c23f693c1ad92b5d5259201bb99807f76ea2a.zip
Diffstat (limited to 'g4f/Provider/needs_auth/Theb.py')
-rw-r--r--g4f/Provider/needs_auth/Theb.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/g4f/Provider/needs_auth/Theb.py b/g4f/Provider/needs_auth/Theb.py
index c35ea592..9803db97 100644
--- a/g4f/Provider/needs_auth/Theb.py
+++ b/g4f/Provider/needs_auth/Theb.py
@@ -2,11 +2,11 @@ from __future__ import annotations
import json
import random
-
import requests
-from ...typing import Any, CreateResult
+from ...typing import Any, CreateResult, Messages
from ..base_provider import BaseProvider
+from ..helper import format_prompt
class Theb(BaseProvider):
@@ -19,12 +19,11 @@ class Theb(BaseProvider):
@staticmethod
def create_completion(
model: str,
- messages: list[dict[str, str]],
- stream: bool, **kwargs: Any) -> CreateResult:
-
- conversation = "\n".join(f"{message['role']}: {message['content']}" for message in messages)
- conversation += "\nassistant: "
-
+ messages: Messages,
+ stream: bool,
+ proxy: str = None,
+ **kwargs
+ ) -> CreateResult:
auth = kwargs.get("auth", {
"bearer_token":"free",
"org_id":"theb",
@@ -54,7 +53,7 @@ class Theb(BaseProvider):
req_rand = random.randint(100000000, 9999999999)
json_data: dict[str, Any] = {
- "text" : conversation,
+ "text" : format_prompt(messages),
"category" : "04f58f64a4aa4191a957b47290fee864",
"model" : "ee8d4f29cb7047f78cbe84313ed6ace8",
"model_params": {
@@ -67,8 +66,13 @@ class Theb(BaseProvider):
}
}
- response = requests.post(f"https://beta.theb.ai/api/conversation?org_id={org_id}&req_rand={req_rand}",
- headers=headers, json=json_data, stream=True)
+ response = requests.post(
+ f"https://beta.theb.ai/api/conversation?org_id={org_id}&req_rand={req_rand}",
+ headers=headers,
+ json=json_data,
+ stream=True,
+ proxies={"https": proxy}
+ )
response.raise_for_status()
content = ""