mirror of
https://github.com/xtekky/gpt4free.git
synced 2026-01-04 00:02:55 -08:00
~ | code styling
This commit is contained in:
parent
5d08c7201f
commit
efd75a11b8
33 changed files with 842 additions and 967 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue