From 9bee0dd5ba145a6687182d53dff497b9ce99932c Mon Sep 17 00:00:00 2001 From: hlohaus <983577+hlohaus@users.noreply.github.com> Date: Sat, 12 Jul 2025 08:29:47 +0200 Subject: [PATCH] Add note to discord --- g4f/Provider/needs_auth/Azure.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/g4f/Provider/needs_auth/Azure.py b/g4f/Provider/needs_auth/Azure.py index 35af569f..8b418dcc 100644 --- a/g4f/Provider/needs_auth/Azure.py +++ b/g4f/Provider/needs_auth/Azure.py @@ -4,13 +4,16 @@ import os import json from ...typing import Messages, AsyncResult +from ...errors import MissingAuthError from ..template import OpenaiTemplate class Azure(OpenaiTemplate): + url = "https://ai.azure.com" api_base = "https://host.g4f.dev/api/Azure" working = True needs_auth = True - login_url = "https://ai.azure.com" + active_by_default = True + login_url = "https://discord.gg/qXA4Wf4Fsm" routes: dict[str, str] = {} @classmethod @@ -39,19 +42,22 @@ class Azure(OpenaiTemplate): model = os.environ.get("AZURE_DEFAULT_MODEL", cls.default_model) if not api_key: raise ValueError("API key is required for Azure provider") - if not api_endpoint: - api_endpoint = os.environ.get("AZURE_API_ENDPOINT") if not api_endpoint: if not cls.routes: cls.get_models() api_endpoint = cls.routes.get(model) if cls.routes and not api_endpoint: raise ValueError(f"No API endpoint found for model: {model}") - async for chunk in super().create_async_generator( - model=model, - messages=messages, - api_key=api_key, - api_endpoint=api_endpoint, - **kwargs - ): - yield chunk \ No newline at end of file + if not api_endpoint: + api_endpoint = os.environ.get("AZURE_API_ENDPOINT") + try: + async for chunk in super().create_async_generator( + model=model, + messages=messages, + api_key=api_key, + api_endpoint=api_endpoint, + **kwargs + ): + yield chunk + except MissingAuthError as e: + raise MissingAuthError(f"{e}. Ask for help in the {cls.login_url} Discord server.") from e \ No newline at end of file