Skip to content

Commit

Permalink
Merge pull request #2549 from evqsx/jmuz_me
Browse files Browse the repository at this point in the history
Add Jmuz provider
  • Loading branch information
hlohaus authored Jan 8, 2025
2 parents fad9f3f + accfadf commit afd09a9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions g4f/Provider/Jmuz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from __future__ import annotations

from ..typing import AsyncResult, Messages
from .needs_auth.OpenaiAPI import OpenaiAPI

class Jmuz(OpenaiAPI):
label = "Jmuz"
api_base = "https://jmuz.me/gpt/api/v2"
api_key = "prod"

working = True
needs_auth = False
supports_stream = True
supports_system_message = False

default_model = 'gpt-4o'

@classmethod
def get_models(cls):
if not cls.models:
cls.models = super().get_models(api_key=cls.api_key, api_base=cls.api_base)
return cls.models

@classmethod
def get_model(cls, model: str, **kwargs) -> str:
if model in cls.get_models():
return model
return cls.default_model

@classmethod
def create_async_generator(
cls,
model: str,
messages: Messages,
stream: bool = False,
**kwargs
) -> AsyncResult:
model = cls.get_model(model)
headers = {
"Authorization": f"Bearer {cls.api_key}",
"Content-Type": "application/json",
"accept": "*/*",
"cache-control": "no-cache",
"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,
api_base=cls.api_base,
api_key=cls.api_key,
stream=cls.supports_stream,
headers=headers,
**kwargs
)
1 change: 1 addition & 0 deletions g4f/Provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .Free2GPT import Free2GPT
from .FreeGpt import FreeGpt
from .GizAI import GizAI
from .Jmuz import Jmuz
from .Liaobots import Liaobots
from .Mhystical import Mhystical
from .PerplexityLabs import PerplexityLabs
Expand Down

0 comments on commit afd09a9

Please sign in to comment.