from __future__ import annotations import time, json, re, asyncio from aiohttp import ClientSession from ...typing import AsyncResult, Messages from ...errors import RateLimitError from ..base_provider import AsyncGeneratorProvider from ..helper import format_prompt class ChatgptDemo(AsyncGeneratorProvider): url = "https://chatgptdemo.info/chat" working = False supports_gpt_35_turbo = True @classmethod async def create_async_generator( cls, model: str, messages: Messages, proxy: str = None, **kwargs ) -> AsyncResult: headers = { "authority": "chatgptdemo.info", "accept-language": "en-US", "origin": "https://chatgptdemo.info", "referer": "https://chatgptdemo.info/chat/", "sec-ch-ua": '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"Linux"', "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" } async with ClientSession(headers=headers) as session: async with session.get(f"{cls.url}/", proxy=proxy) as response: response.raise_for_status() text = await response.text() result = re.search( r'