mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-23 09:10:13 +03:00
6ef282de3a
Fix many providers Add selenium-wire to requierments
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from aiohttp import ClientSession
|
|
|
|
from ..typing import AsyncResult, Messages
|
|
from .base_provider import AsyncGeneratorProvider
|
|
from ..requests import get_args_from_browser
|
|
from ..webdriver import WebDriver
|
|
|
|
class Aura(AsyncGeneratorProvider):
|
|
url = "https://openchat.team"
|
|
working = True
|
|
|
|
@classmethod
|
|
async def create_async_generator(
|
|
cls,
|
|
model: str,
|
|
messages: Messages,
|
|
proxy: str = None,
|
|
webdriver: WebDriver = None,
|
|
**kwargs
|
|
) -> AsyncResult:
|
|
args = get_args_from_browser(cls.url, webdriver, proxy)
|
|
async with ClientSession(**args) as session:
|
|
new_messages = []
|
|
system_message = []
|
|
for message in messages:
|
|
if message["role"] == "system":
|
|
system_message.append(message["content"])
|
|
else:
|
|
new_messages.append(message)
|
|
data = {
|
|
"model": {
|
|
"id": "openchat_v3.2_mistral",
|
|
"name": "OpenChat Aura",
|
|
"maxLength": 24576,
|
|
"tokenLimit": 8192
|
|
},
|
|
"messages": new_messages,
|
|
"key": "",
|
|
"prompt": "\n".join(system_message),
|
|
"temperature": 0.5
|
|
}
|
|
async with session.post(f"{cls.url}/api/chat", json=data, proxy=proxy) as response:
|
|
response.raise_for_status()
|
|
async for chunk in response.content.iter_any():
|
|
yield chunk.decode() |