GptChatly.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from __future__ import annotations
  2. from ..requests import Session, get_session_from_browser
  3. from ..typing import Messages
  4. from .base_provider import AsyncProvider
  5. class GptChatly(AsyncProvider):
  6. url = "https://gptchatly.com"
  7. working = True
  8. supports_message_history = True
  9. supports_gpt_35_turbo = True
  10. supports_gpt_4 = True
  11. @classmethod
  12. async def create_async(
  13. cls,
  14. model: str,
  15. messages: Messages,
  16. proxy: str = None,
  17. timeout: int = 120,
  18. session: Session = None,
  19. **kwargs
  20. ) -> str:
  21. if not session:
  22. session = get_session_from_browser(cls.url, proxy=proxy, timeout=timeout)
  23. if model.startswith("gpt-4"):
  24. chat_url = f"{cls.url}/fetch-gpt4-response"
  25. else:
  26. chat_url = f"{cls.url}/felch-response"
  27. data = {
  28. "past_conversations": messages
  29. }
  30. response = session.post(chat_url, json=data)
  31. response.raise_for_status()
  32. return response.json()["chatGPTResponse"]