summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/Theb.py
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner@lohaus.eu>2023-10-09 13:33:20 +0200
committerHeiner Lohaus <heiner@lohaus.eu>2023-10-09 13:33:20 +0200
commitc6b33e527c9af9c72a615a7b23c8d40b5783862f (patch)
tree26a25d7b5bee6ba1e2ac484e1ad124a8e52b0b43 /g4f/Provider/needs_auth/Theb.py
parentReadme: Create Provider with AI Tool (diff)
downloadgpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.tar
gpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.tar.gz
gpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.tar.bz2
gpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.tar.lz
gpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.tar.xz
gpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.tar.zst
gpt4free-c6b33e527c9af9c72a615a7b23c8d40b5783862f.zip
Diffstat (limited to '')
-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 = ""