XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Add note to discord

9bee0dd5
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +17 -11
Modified g4f/Provider/needs_auth/Azure.py +17 -11
@@ -4,13 +4,16 @@ import os
4 4 import json
5 5
6 6 from ...typing import Messages, AsyncResult
7 from ...errors import MissingAuthError
7 8 from ..template import OpenaiTemplate
8 9
9 10 class Azure(OpenaiTemplate):
11 url = "https://ai.azure.com"
10 12 api_base = "https://host.g4f.dev/api/Azure"
11 13 working = True
12 14 needs_auth = True
13 login_url = "https://ai.azure.com"
15 active_by_default = True
16 login_url = "https://discord.gg/qXA4Wf4Fsm"
14 17 routes: dict[str, str] = {}
15 18
16 19 @classmethod
@@ -39,19 +42,22 @@ class Azure(OpenaiTemplate):
39 42 model = os.environ.get("AZURE_DEFAULT_MODEL", cls.default_model)
40 43 if not api_key:
41 44 raise ValueError("API key is required for Azure provider")
42 if not api_endpoint:
43 api_endpoint = os.environ.get("AZURE_API_ENDPOINT")
44 45 if not api_endpoint:
45 46 if not cls.routes:
46 47 cls.get_models()
47 48 api_endpoint = cls.routes.get(model)
48 49 if cls.routes and not api_endpoint:
49 50 raise ValueError(f"No API endpoint found for model: {model}")
50 async for chunk in super().create_async_generator(
51 model=model,
52 messages=messages,
53 api_key=api_key,
54 api_endpoint=api_endpoint,
55 **kwargs
56 ):
57 yield chunk
51 if not api_endpoint:
52 api_endpoint = os.environ.get("AZURE_API_ENDPOINT")
53 try:
54 async for chunk in super().create_async_generator(
55 model=model,
56 messages=messages,
57 api_key=api_key,
58 api_endpoint=api_endpoint,
59 **kwargs
60 ):
61 yield chunk
62 except MissingAuthError as e:
63 raise MissingAuthError(f"{e}. Ask for help in the {cls.login_url} Discord server.") from e