mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
Enhance Yupp provider to support API key management in model fetching
This commit is contained in:
parent
ef0867c0dc
commit
fec4185215
2 changed files with 16 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ from ..providers.base_provider import AbstractProvider, ProviderModelMixin
|
|||
from ..providers.response import Reasoning, PlainTextResponse, PreviewResponse
|
||||
from ..errors import RateLimitError, ProviderException
|
||||
from ..cookies import get_cookies
|
||||
from ..tools.auth import AuthManager
|
||||
from .yupp.models import YuppModelManager
|
||||
from ..debug import log
|
||||
|
||||
|
|
@ -161,11 +162,16 @@ class Yupp(AbstractProvider, ProviderModelMixin):
|
|||
active_by_default = True
|
||||
|
||||
@classmethod
|
||||
def get_models(cls) -> List[Dict[str, Any]]:
|
||||
def get_models(cls, api_key: str = None, **kwargs) -> List[Dict[str, Any]]:
|
||||
if not cls.models:
|
||||
manager = YuppModelManager()
|
||||
if not api_key:
|
||||
api_key = AuthManager.load_api_key(cls)
|
||||
if not api_key:
|
||||
api_key = get_cookies("yupp.ai", False).get("__Secure-yupp.session-token")
|
||||
manager = YuppModelManager(api_key=api_key)
|
||||
models = manager.client.fetch_models()
|
||||
cls.models = [model.get("name") for model in models]
|
||||
if models:
|
||||
cls.models = [model.get("name") for model in models]
|
||||
return cls.models
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue