Mhystical.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from __future__ import annotations
  2. from ..typing import AsyncResult, Messages
  3. from .needs_auth.OpenaiTemplate import OpenaiTemplate
  4. class Mhystical(OpenaiTemplate):
  5. url = "https://mhystical.cc"
  6. api_endpoint = "https://api.mhystical.cc/v1/completions"
  7. login_url = "https://mhystical.cc/dashboard"
  8. api_key = "mhystical"
  9. working = True
  10. supports_stream = False # Set to False, as streaming is not specified in ChatifyAI
  11. supports_system_message = False
  12. default_model = 'gpt-4'
  13. models = [default_model]
  14. @classmethod
  15. def get_model(cls, model: str, **kwargs) -> str:
  16. cls.last_model = cls.default_model
  17. return cls.default_model
  18. @classmethod
  19. def create_async_generator(
  20. cls,
  21. model: str,
  22. messages: Messages,
  23. stream: bool = False,
  24. api_key: str = None,
  25. **kwargs
  26. ) -> AsyncResult:
  27. headers = {
  28. "x-api-key": cls.api_key,
  29. "Content-Type": "application/json",
  30. "accept": "*/*",
  31. "cache-control": "no-cache",
  32. "origin": cls.url,
  33. "referer": f"{cls.url}/",
  34. "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
  35. }
  36. return super().create_async_generator(
  37. model=model,
  38. messages=messages,
  39. stream=cls.supports_stream,
  40. api_endpoint=cls.api_endpoint,
  41. headers=headers,
  42. **kwargs
  43. )