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

XFEstudio/gpt4free

Add models_needs_auth flag to Groq provider and enhance get_models method to load API key

3df3595e
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +7 -1
Modified g4f/Provider/needs_auth/Groq.py +1 -0
@@ -9,6 +9,7 @@ class Groq(OpenaiTemplate):
9 9 api_base = "https://api.groq.com/openai/v1"
10 10 working = True
11 11 needs_auth = True
12 models_needs_auth = True
12 13 active_by_default = True
13 14 default_model = DEFAULT_MODEL
14 15 fallback_models = [
Modified g4f/providers/base_provider.py +6 -1
@@ -21,6 +21,7 @@ from .response import BaseConversation, AuthResult
21 21 from .helper import concat_chunks
22 22 from ..cookies import get_cookies_dir
23 23 from ..errors import ModelNotFoundError, ResponseError, MissingAuthError, NoValidHarFileError, PaymentRequiredError, CloudflareError
24 from ..tools.run_tools import AuthManager
24 25 from .. import debug
25 26
26 27 SAFE_PARAMETERS = [
@@ -374,12 +375,16 @@ class ProviderModelMixin:
374 375 models_loaded: bool = False
375 376
376 377 @classmethod
377 def get_models(cls, **kwargs) -> list[str]:
378 def get_models(cls, api_key: str = None, **kwargs) -> list[str]:
378 379 if not cls.models and cls.default_model is not None:
379 380 cls.models = [cls.default_model]
380 381 if not cls.models_loaded and hasattr(cls, "get_cache_file"):
381 382 if cls.get_cache_file().exists():
382 383 cls.live += 1
384 elif not api_key:
385 api_key = AuthManager.load_api_key(cls)
386 if api_key:
387 cls.live += 1
383 388 cls.models_loaded = True
384 389 return cls.models
385 390