mirror of https://github.com/xtekky/gpt4free
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
1 year ago
|
from __future__ import annotations
|
||
|
|
||
1 year ago
|
from aiohttp import ClientSession
|
||
1 year ago
|
|
||
11 months ago
|
from ...typing import AsyncResult, Messages
|
||
|
from ..base_provider import AsyncGeneratorProvider
|
||
1 year ago
|
|
||
|
|
||
1 year ago
|
class Acytoo(AsyncGeneratorProvider):
|
||
|
url = 'https://chat.acytoo.com'
|
||
12 months ago
|
working = False
|
||
11 months ago
|
supports_message_history = True
|
||
1 year ago
|
supports_gpt_35_turbo = True
|
||
|
|
||
1 year ago
|
@classmethod
|
||
1 year ago
|
async def create_async_generator(
|
||
1 year ago
|
cls,
|
||
1 year ago
|
model: str,
|
||
1 year ago
|
messages: Messages,
|
||
1 year ago
|
proxy: str = None,
|
||
|
**kwargs
|
||
1 year ago
|
) -> AsyncResult:
|
||
1 year ago
|
async with ClientSession(
|
||
|
headers=_create_header()
|
||
|
) as session:
|
||
|
async with session.post(
|
||
1 year ago
|
f'{cls.url}/api/completions',
|
||
1 year ago
|
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()
|
||
1 year ago
|
|
||
|
|
||
|
def _create_header():
|
||
|
return {
|
||
1 year ago
|
'accept': '*/*',
|
||
|
'content-type': 'application/json',
|
||
1 year ago
|
}
|
||
|
|
||
|
|
||
1 year ago
|
def _create_payload(messages: Messages, temperature: float = 0.5, **kwargs):
|
||
1 year ago
|
return {
|
||
1 year ago
|
'key' : '',
|
||
|
'model' : 'gpt-3.5-turbo',
|
||
1 year ago
|
'messages' : messages,
|
||
1 year ago
|
'temperature' : temperature,
|
||
|
'password' : ''
|
||
|
}
|