summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-11-20 02:34:47 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-11-20 02:34:47 +0100
commit58fa409eefcc8ae0233967dc807b046ad77bf6fa (patch)
tree845faa57ad66bf08fdef6462c8dc34f47d9c2bca /g4f/gui/server
parentAdd --cookie-browsers argument to cli (diff)
downloadgpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.tar
gpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.tar.gz
gpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.tar.bz2
gpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.tar.lz
gpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.tar.xz
gpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.tar.zst
gpt4free-58fa409eefcc8ae0233967dc807b046ad77bf6fa.zip
Diffstat (limited to 'g4f/gui/server')
-rw-r--r--g4f/gui/server/api.py5
-rw-r--r--g4f/gui/server/backend.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/g4f/gui/server/api.py b/g4f/gui/server/api.py
index 6be77d09..2d871ff3 100644
--- a/g4f/gui/server/api.py
+++ b/g4f/gui/server/api.py
@@ -38,10 +38,11 @@ class Api:
return models._all_models
@staticmethod
- def get_provider_models(provider: str) -> list[dict]:
+ def get_provider_models(provider: str, api_key: str = None) -> list[dict]:
if provider in __map__:
provider: ProviderType = __map__[provider]
if issubclass(provider, ProviderModelMixin):
+ models = provider.get_models() if api_key is None else provider.get_models(api_key=api_key)
return [
{
"model": model,
@@ -49,7 +50,7 @@ class Api:
"vision": getattr(provider, "default_vision_model", None) == model or model in getattr(provider, "vision_models", []),
"image": model in getattr(provider, "image_models", []),
}
- for model in provider.get_models()
+ for model in models
]
return []
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py
index dc1b1080..020e49ef 100644
--- a/g4f/gui/server/backend.py
+++ b/g4f/gui/server/backend.py
@@ -94,7 +94,8 @@ class Backend_Api(Api):
)
def get_provider_models(self, provider: str):
- models = super().get_provider_models(provider)
+ api_key = None if request.authorization is None else request.authorization.token
+ models = super().get_provider_models(provider, api_key)
if models is None:
return 404, "Provider not found"
return models