mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
Add models_needs_auth flag to Groq provider and enhance get_models method to load API key
This commit is contained in:
parent
5bfea4611a
commit
3df3595e63
2 changed files with 7 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ class Groq(OpenaiTemplate):
|
|||
api_base = "https://api.groq.com/openai/v1"
|
||||
working = True
|
||||
needs_auth = True
|
||||
models_needs_auth = True
|
||||
active_by_default = True
|
||||
default_model = DEFAULT_MODEL
|
||||
fallback_models = [
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from .response import BaseConversation, AuthResult
|
|||
from .helper import concat_chunks
|
||||
from ..cookies import get_cookies_dir
|
||||
from ..errors import ModelNotFoundError, ResponseError, MissingAuthError, NoValidHarFileError, PaymentRequiredError, CloudflareError
|
||||
from ..tools.run_tools import AuthManager
|
||||
from .. import debug
|
||||
|
||||
SAFE_PARAMETERS = [
|
||||
|
|
@ -374,12 +375,16 @@ class ProviderModelMixin:
|
|||
models_loaded: bool = False
|
||||
|
||||
@classmethod
|
||||
def get_models(cls, **kwargs) -> list[str]:
|
||||
def get_models(cls, api_key: str = None, **kwargs) -> list[str]:
|
||||
if not cls.models and cls.default_model is not None:
|
||||
cls.models = [cls.default_model]
|
||||
if not cls.models_loaded and hasattr(cls, "get_cache_file"):
|
||||
if cls.get_cache_file().exists():
|
||||
cls.live += 1
|
||||
elif not api_key:
|
||||
api_key = AuthManager.load_api_key(cls)
|
||||
if api_key:
|
||||
cls.live += 1
|
||||
cls.models_loaded = True
|
||||
return cls.models
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue