From 2df2d6b0cf63fa90b0fe5160a02dade7d161f667 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Tue, 14 Jan 2025 17:07:39 +0100 Subject: Read FinishReason and Usage from Gemini API Add "Custom Provider": Set API Url in the settings Remove Discord link from result, add them to attr: Jmuz Fix Bug: File content are added to the prompt Changed response from /v1/models API Disable Pizzagpt Provider --- g4f/Provider/Jmuz.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'g4f/Provider/Jmuz.py') diff --git a/g4f/Provider/Jmuz.py b/g4f/Provider/Jmuz.py index c713398b..a5084fc0 100644 --- a/g4f/Provider/Jmuz.py +++ b/g4f/Provider/Jmuz.py @@ -5,7 +5,7 @@ from .needs_auth.OpenaiAPI import OpenaiAPI class Jmuz(OpenaiAPI): label = "Jmuz" - url = "https://jmuz.me" + url = "https://discord.gg/qXfu24JmsB" login_url = None api_base = "https://jmuz.me/gpt/api/v2" api_key = "prod" @@ -15,7 +15,7 @@ class Jmuz(OpenaiAPI): supports_stream = True supports_system_message = False - default_model = 'gpt-4o' + default_model = "gpt-4o" model_aliases = { "gemini": "gemini-exp", "deepseek-chat": "deepseek-2.5", @@ -29,13 +29,7 @@ class Jmuz(OpenaiAPI): 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( + async def create_async_generator( cls, model: str, messages: Messages, @@ -52,7 +46,8 @@ class Jmuz(OpenaiAPI): "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( + started = False + async for chunk in super().create_async_generator( model=model, messages=messages, api_base=cls.api_base, @@ -60,4 +55,11 @@ class Jmuz(OpenaiAPI): stream=cls.supports_stream, headers=headers, **kwargs - ) + ): + if isinstance(chunk, str) and cls.url in chunk: + continue + if isinstance(chunk, str) and not started: + chunk = chunk.lstrip() + if chunk: + started = True + yield chunk -- cgit v1.2.3