summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Liaobots.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider/Liaobots.py')
-rw-r--r--g4f/Provider/Liaobots.py51
1 files changed, 23 insertions, 28 deletions
diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py
index a969b643..a8bb83e8 100644
--- a/g4f/Provider/Liaobots.py
+++ b/g4f/Provider/Liaobots.py
@@ -1,33 +1,31 @@
-import uuid
+import uuid, requests
-import requests
-
-from ..typing import Any, CreateResult
+from ..typing import Any, CreateResult
from .base_provider import BaseProvider
class Liaobots(BaseProvider):
- url = "https://liaobots.com"
- supports_stream = True
- needs_auth = True
- supports_gpt_35_turbo = True
- supports_gpt_4 = True
+ url: str = "https://liaobots.com"
+ supports_stream = True
+ needs_auth = True
+ supports_gpt_35_turbo = True
+ supports_gpt_4 = True
@staticmethod
def create_completion(
model: str,
messages: list[dict[str, str]],
- stream: bool,
- **kwargs: Any,
- ) -> CreateResult:
+ stream: bool, **kwargs: Any) -> CreateResult:
+
headers = {
- "authority": "liaobots.com",
- "content-type": "application/json",
- "origin": "https://liaobots.com",
- "referer": "https://liaobots.com/",
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
- "x-auth-code": str(kwargs.get("auth")),
+ "authority" : "liaobots.com",
+ "content-type" : "application/json",
+ "origin" : "https://liaobots.com",
+ "referer" : "https://liaobots.com/",
+ "user-agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
+ "x-auth-code" : str(kwargs.get("auth")),
}
+
models = {
"gpt-4": {
"id": "gpt-4",
@@ -44,18 +42,15 @@ class Liaobots(BaseProvider):
}
json_data = {
"conversationId": str(uuid.uuid4()),
- "model": models[model],
- "messages": messages,
- "key": "",
- "prompt": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
+ "model" : models[model],
+ "messages" : messages,
+ "key" : "",
+ "prompt" : "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
}
- response = requests.post(
- "https://liaobots.com/api/chat",
- headers=headers,
- json=json_data,
- stream=True,
- )
+ response = requests.post("https://liaobots.com/api/chat",
+ headers=headers, json=json_data, stream=True)
+
response.raise_for_status()
for token in response.iter_content(chunk_size=2046):
yield token.decode("utf-8")