Skip to content

Commit afd09a9

Browse files
authored
Merge pull request #2549 from evqsx/jmuz_me
Add Jmuz provider
2 parents fad9f3f + accfadf commit afd09a9

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

g4f/Provider/Jmuz.py

+54
Original file line numberDiff line numberDiff line change
@@ -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+
)

g4f/Provider/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .Free2GPT import Free2GPT
2828
from .FreeGpt import FreeGpt
2929
from .GizAI import GizAI
30+
from .Jmuz import Jmuz
3031
from .Liaobots import Liaobots
3132
from .Mhystical import Mhystical
3233
from .PerplexityLabs import PerplexityLabs

0 commit comments

Comments
 (0)