2023-08-27 19:43:45 -04:00
|
|
|
from aiohttp import ClientSession
|
2023-07-28 06:07:17 -04:00
|
|
|
|
2023-08-27 19:43:45 -04:00
|
|
|
from .base_provider import AsyncProvider, format_prompt
|
2023-07-28 06:07:17 -04:00
|
|
|
|
|
|
|
|
2023-08-27 19:43:45 -04:00
|
|
|
class Yqcloud(AsyncProvider):
|
|
|
|
url = "https://chat9.yqcloud.top/"
|
|
|
|
working = True
|
|
|
|
supports_gpt_35_turbo = True
|
2023-07-28 06:07:17 -04:00
|
|
|
|
|
|
|
@staticmethod
|
2023-08-27 19:43:45 -04:00
|
|
|
async def create_async(
|
2023-07-28 06:07:17 -04:00
|
|
|
model: str,
|
|
|
|
messages: list[dict[str, str]],
|
2023-08-27 19:43:45 -04:00
|
|
|
proxy: str = None,
|
|
|
|
**kwargs,
|
|
|
|
) -> str:
|
|
|
|
async with ClientSession(
|
|
|
|
headers=_create_header()
|
|
|
|
) as session:
|
|
|
|
payload = _create_payload(messages)
|
|
|
|
async with session.post("https://api.aichatos.cloud/api/generateStream", proxy=proxy, json=payload) as response:
|
|
|
|
response.raise_for_status()
|
|
|
|
return await response.text()
|
2023-07-28 06:07:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
def _create_header():
|
|
|
|
return {
|
2023-08-27 11:37:44 -04:00
|
|
|
"accept" : "application/json, text/plain, */*",
|
|
|
|
"content-type" : "application/json",
|
|
|
|
"origin" : "https://chat9.yqcloud.top",
|
2023-07-28 06:07:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def _create_payload(messages: list[dict[str, str]]):
|
|
|
|
return {
|
2023-08-27 19:43:45 -04:00
|
|
|
"prompt": format_prompt(messages),
|
|
|
|
"network": True,
|
|
|
|
"system": "",
|
2023-07-28 06:07:17 -04:00
|
|
|
"withoutContext": False,
|
2023-08-27 19:43:45 -04:00
|
|
|
"stream": False,
|
|
|
|
"userId": "#/chat/1693025544336"
|
|
|
|
}
|