forked from xtekky/gpt4free
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMhystical.py
61 lines (53 loc) · 1.71 KB
/
Mhystical.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from __future__ import annotations
from ..typing import AsyncResult, Messages
from .needs_auth.OpenaiAPI import OpenaiAPI
"""
Mhystical.cc
~~~~~~~~~~~~
Author: NoelP.dev
Last Updated: 2024-05-11
Author Site: https://noelp.dev
Provider Site: https://mhystical.cc
"""
class Mhystical(OpenaiAPI):
label = "Mhystical"
url = "https://mhystical.cc"
api_endpoint = "https://api.mhystical.cc/v1/completions"
login_url = "https://mhystical.cc/dashboard"
working = True
needs_auth = False
supports_stream = False # Set to False, as streaming is not specified in ChatifyAI
supports_system_message = False
default_model = 'gpt-4'
models = [default_model]
@classmethod
def get_model(cls, model: str, **kwargs) -> str:
cls.last_model = cls.default_model
return cls.default_model
@classmethod
def create_async_generator(
cls,
model: str,
messages: Messages,
stream: bool = False,
api_key: str = "mhystical",
**kwargs
) -> AsyncResult:
model = cls.get_model(model)
headers = {
"x-api-key": api_key,
"Content-Type": "application/json",
"accept": "*/*",
"cache-control": "no-cache",
"origin": cls.url,
"referer": f"{cls.url}/",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
}
return super().create_async_generator(
model=model,
messages=messages,
stream=cls.supports_stream,
api_endpoint=cls.api_endpoint,
headers=headers,
**kwargs
)