summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/not_working/Aura.py
blob: e841d909329252bbe9d359998f2fa30315761aca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 = False

    @classmethod
    async def create_async_generator(
        cls,
        model: str,
        messages: Messages,
        proxy: str = None,
        temperature: float = 0.5,
        max_tokens: int = 8192,
        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_3.6",
                    "name": "OpenChat 3.6 (latest)",
                    "maxLength": 24576,
                    "tokenLimit": max_tokens
                },
                "messages": new_messages,
                "key": "",
                "prompt": "\n".join(system_message),
                "temperature": temperature
            }
            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(error="ignore")