2023-09-03 08:26:26 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-09-05 15:27:24 +00:00
|
|
|
from aiohttp import ClientSession
|
2023-07-28 10:07:17 +00:00
|
|
|
|
2023-11-13 17:58:52 +00:00
|
|
|
from ...typing import AsyncResult, Messages
|
|
|
|
from ..base_provider import AsyncGeneratorProvider
|
2023-07-28 10:07:17 +00:00
|
|
|
|
|
|
|
|
2023-09-05 15:27:24 +00:00
|
|
|
class Acytoo(AsyncGeneratorProvider):
|
|
|
|
url = 'https://chat.acytoo.com'
|
2023-10-15 23:47:10 +00:00
|
|
|
working = False
|
2023-10-27 20:59:14 +00:00
|
|
|
supports_message_history = True
|
2023-07-28 10:07:17 +00:00
|
|
|
supports_gpt_35_turbo = True
|
|
|
|
|
2023-08-24 19:32:22 +00:00
|
|
|
@classmethod
|
2023-09-05 15:27:24 +00:00
|
|
|
async def create_async_generator(
|
2023-08-24 19:32:22 +00:00
|
|
|
cls,
|
2023-07-28 10:07:17 +00:00
|
|
|
model: str,
|
2023-10-09 08:22:17 +00:00
|
|
|
messages: Messages,
|
2023-09-05 15:27:24 +00:00
|
|
|
proxy: str = None,
|
|
|
|
**kwargs
|
2023-10-09 08:22:17 +00:00
|
|
|
) -> AsyncResult:
|
2023-09-05 15:27:24 +00:00
|
|
|
async with ClientSession(
|
|
|
|
headers=_create_header()
|
|
|
|
) as session:
|
|
|
|
async with session.post(
|
2023-10-10 07:49:29 +00:00
|
|
|
f'{cls.url}/api/completions',
|
2023-09-05 15:27:24 +00:00
|
|
|
proxy=proxy,
|
|
|
|
json=_create_payload(messages, **kwargs)
|
|
|
|
) as response:
|
|
|
|
response.raise_for_status()
|
|
|
|
async for stream in response.content.iter_any():
|
|
|
|
if stream:
|
|
|
|
yield stream.decode()
|
2023-07-28 10:07:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _create_header():
|
|
|
|
return {
|
2023-08-27 15:37:44 +00:00
|
|
|
'accept': '*/*',
|
|
|
|
'content-type': 'application/json',
|
2023-07-28 10:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-10 07:49:29 +00:00
|
|
|
def _create_payload(messages: Messages, temperature: float = 0.5, **kwargs):
|
2023-07-28 10:07:17 +00:00
|
|
|
return {
|
2023-08-27 15:37:44 +00:00
|
|
|
'key' : '',
|
|
|
|
'model' : 'gpt-3.5-turbo',
|
2023-09-05 15:27:24 +00:00
|
|
|
'messages' : messages,
|
2023-08-27 15:37:44 +00:00
|
|
|
'temperature' : temperature,
|
|
|
|
'password' : ''
|
|
|
|
}
|