mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 10:40:43 -08:00
Add note to discord
This commit is contained in:
parent
e48ca345b5
commit
9bee0dd5ba
1 changed files with 17 additions and 11 deletions
|
|
@ -4,13 +4,16 @@ import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from ...typing import Messages, AsyncResult
|
from ...typing import Messages, AsyncResult
|
||||||
|
from ...errors import MissingAuthError
|
||||||
from ..template import OpenaiTemplate
|
from ..template import OpenaiTemplate
|
||||||
|
|
||||||
class Azure(OpenaiTemplate):
|
class Azure(OpenaiTemplate):
|
||||||
|
url = "https://ai.azure.com"
|
||||||
api_base = "https://host.g4f.dev/api/Azure"
|
api_base = "https://host.g4f.dev/api/Azure"
|
||||||
working = True
|
working = True
|
||||||
needs_auth = True
|
needs_auth = True
|
||||||
login_url = "https://ai.azure.com"
|
active_by_default = True
|
||||||
|
login_url = "https://discord.gg/qXA4Wf4Fsm"
|
||||||
routes: dict[str, str] = {}
|
routes: dict[str, str] = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -39,14 +42,15 @@ class Azure(OpenaiTemplate):
|
||||||
model = os.environ.get("AZURE_DEFAULT_MODEL", cls.default_model)
|
model = os.environ.get("AZURE_DEFAULT_MODEL", cls.default_model)
|
||||||
if not api_key:
|
if not api_key:
|
||||||
raise ValueError("API key is required for Azure provider")
|
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 api_endpoint:
|
||||||
if not cls.routes:
|
if not cls.routes:
|
||||||
cls.get_models()
|
cls.get_models()
|
||||||
api_endpoint = cls.routes.get(model)
|
api_endpoint = cls.routes.get(model)
|
||||||
if cls.routes and not api_endpoint:
|
if cls.routes and not api_endpoint:
|
||||||
raise ValueError(f"No API endpoint found for model: {model}")
|
raise ValueError(f"No API endpoint found for model: {model}")
|
||||||
|
if not api_endpoint:
|
||||||
|
api_endpoint = os.environ.get("AZURE_API_ENDPOINT")
|
||||||
|
try:
|
||||||
async for chunk in super().create_async_generator(
|
async for chunk in super().create_async_generator(
|
||||||
model=model,
|
model=model,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
|
|
@ -55,3 +59,5 @@ class Azure(OpenaiTemplate):
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
yield chunk
|
yield chunk
|
||||||
|
except MissingAuthError as e:
|
||||||
|
raise MissingAuthError(f"{e}. Ask for help in the {cls.login_url} Discord server.") from e
|
||||||
Loading…
Add table
Add a link
Reference in a new issue