Gpt6.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from __future__ import annotations
  2. import json
  3. from aiohttp import ClientSession
  4. from ..typing import AsyncResult, Messages
  5. from .base_provider import AsyncGeneratorProvider
  6. from .helper import format_prompt
  7. class Gpt6(AsyncGeneratorProvider):
  8. url = "https://gpt6.ai"
  9. working = True
  10. supports_gpt_35_turbo = True
  11. @classmethod
  12. async def create_async_generator(
  13. cls,
  14. model: str,
  15. messages: Messages,
  16. proxy: str = None,
  17. **kwargs
  18. ) -> AsyncResult:
  19. headers = {
  20. "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0",
  21. "Accept": "*/*",
  22. "Accept-Language": "de,en-US;q=0.7,en;q=0.3",
  23. "Accept-Encoding": "gzip, deflate, br",
  24. "Content-Type": "application/json",
  25. "Origin": "https://gpt6.ai",
  26. "Connection": "keep-alive",
  27. "Referer": "https://gpt6.ai/",
  28. "Sec-Fetch-Dest": "empty",
  29. "Sec-Fetch-Mode": "cors",
  30. "Sec-Fetch-Site": "cross-site",
  31. "TE": "trailers",
  32. }
  33. async with ClientSession(headers=headers) as session:
  34. data = {
  35. "prompts":messages,
  36. "geoInfo":{"ip":"100.90.100.222","hostname":"ip-100-090-100-222.um36.pools.vodafone-ip.de","city":"Muenchen","region":"North Rhine-Westphalia","country":"DE","loc":"44.0910,5.5827","org":"AS3209 Vodafone GmbH","postal":"41507","timezone":"Europe/Berlin"},
  37. "paid":False,
  38. "character":{"textContent":"","id":"52690ad6-22e4-4674-93d4-1784721e9944","name":"GPT6","htmlContent":""}
  39. }
  40. async with session.post(f"https://seahorse-app-d29hu.ondigitalocean.app/api/v1/query", json=data, proxy=proxy) as response:
  41. response.raise_for_status()
  42. async for line in response.content:
  43. if line.startswith(b"data: [DONE]"):
  44. break
  45. elif line.startswith(b"data: "):
  46. line = json.loads(line[6:-1])
  47. chunk = line["choices"][0]["delta"].get("content")
  48. if chunk:
  49. yield chunk