返回提交历史
Added
g4f/Provider/Jmuz.py
+54
-0
Modified
g4f/Provider/__init__.py
+1
-0
XFEstudio/gpt4free
Add Jmuz provider
accfadf9
代码差异
2 个文件
+55
-0
@@ -0,0 +1,54 @@
1
from __future__ import annotations
2
3
from ..typing import AsyncResult, Messages
4
from .needs_auth.OpenaiAPI import OpenaiAPI
5
6
class Jmuz(OpenaiAPI):
7
label = "Jmuz"
8
api_base = "https://jmuz.me/gpt/api/v2"
9
api_key = "prod"
10
11
working = True
12
needs_auth = False
13
supports_stream = True
14
supports_system_message = False
15
16
default_model = 'gpt-4o'
17
18
@classmethod
19
def get_models(cls):
20
if not cls.models:
21
cls.models = super().get_models(api_key=cls.api_key, api_base=cls.api_base)
22
return cls.models
23
24
@classmethod
25
def get_model(cls, model: str, **kwargs) -> str:
26
if model in cls.get_models():
27
return model
28
return cls.default_model
29
30
@classmethod
31
def create_async_generator(
32
cls,
33
model: str,
34
messages: Messages,
35
stream: bool = False,
36
**kwargs
37
) -> AsyncResult:
38
model = cls.get_model(model)
39
headers = {
40
"Authorization": f"Bearer {cls.api_key}",
41
"Content-Type": "application/json",
42
"accept": "*/*",
43
"cache-control": "no-cache",
44
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
45
}
46
return super().create_async_generator(
47
model=model,
48
messages=messages,
49
api_base=cls.api_base,
50
api_key=cls.api_key,
51
stream=cls.supports_stream,
52
headers=headers,
53
**kwargs
54
)
@@ -27,6 +27,7 @@ from .DeepInfraChat import DeepInfraChat
27
27
from .Free2GPT import Free2GPT
28
28
from .FreeGpt import FreeGpt
29
29
from .GizAI import GizAI
30
from .Jmuz import Jmuz
30
31
from .Liaobots import Liaobots
31
32
from .Mhystical import Mhystical
32
33
from .PerplexityLabs import PerplexityLabs