GptChatly.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. @classmethod
  11. async def create_async(
  12. cls,
  13. model: str,
  14. messages: Messages,
  15. proxy: str = None,
  16. timeout: int = 120,
  17. session: Session = None,
  18. **kwargs
  19. ) -> str:
  20. if not session:
  21. session = get_session_from_browser(cls.url, proxy=proxy, timeout=timeout)
  22. if model.startswith("gpt-4"):
  23. chat_url = f"{cls.url}/fetch-gpt4-response"
  24. else:
  25. chat_url = f"{cls.url}/felch-response"
  26. data = {
  27. "past_conversations": messages
  28. }
  29. response = session.post(chat_url, json=data)
  30. response.raise_for_status()
  31. return response.json()["chatGPTResponse"]