diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-04-22 01:35:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-22 01:35:07 +0200 |
commit | 4b4d1f08b5c75c8c8932b5edfbb0d020f8e029a7 (patch) | |
tree | 6ed0cfc6cd53a3ab32565d6199a929ac1ea6ad80 /g4f/gui/server/api.py | |
parent | Merge pull request #1869 from hlohaus/carst (diff) | |
parent | Add vision models to readme (diff) | |
download | gpt4free-0.3.0.4.tar gpt4free-0.3.0.4.tar.gz gpt4free-0.3.0.4.tar.bz2 gpt4free-0.3.0.4.tar.lz gpt4free-0.3.0.4.tar.xz gpt4free-0.3.0.4.tar.zst gpt4free-0.3.0.4.zip |
Diffstat (limited to 'g4f/gui/server/api.py')
-rw-r--r-- | g4f/gui/server/api.py | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/g4f/gui/server/api.py b/g4f/gui/server/api.py index 47c25eb7..3d9f6a1c 100644 --- a/g4f/gui/server/api.py +++ b/g4f/gui/server/api.py @@ -16,7 +16,8 @@ conversations: dict[dict[str, BaseConversation]] = {} class Api(): - def get_models(self) -> list[str]: + @staticmethod + def get_models() -> list[str]: """ Return a list of all models. @@ -27,7 +28,8 @@ class Api(): """ return models._all_models - def get_provider_models(self, provider: str) -> list[dict]: + @staticmethod + def get_provider_models(provider: str) -> list[dict]: if provider in __map__: provider: ProviderType = __map__[provider] if issubclass(provider, ProviderModelMixin): @@ -40,7 +42,28 @@ class Api(): else: return []; - def get_providers(self) -> list[str]: + @staticmethod + def get_image_models() -> list[dict]: + image_models = [] + for provider in __providers__: + if hasattr(provider, "image_models"): + if hasattr(provider, "get_models"): + provider.get_models() + parent = provider + if hasattr(provider, "parent"): + parent = __map__[provider.parent] + for model in provider.image_models: + image_models.append({ + "provider": parent.__name__, + "url": parent.url, + "label": parent.label if hasattr(parent, "label") else None, + "image_model": model, + "vision_model": parent.default_vision_model if hasattr(parent, "default_vision_model") else None + }) + return image_models + + @staticmethod + def get_providers() -> list[str]: """ Return a list of all working providers. """ @@ -58,7 +81,8 @@ class Api(): if provider.working } - def get_version(self): + @staticmethod + def get_version(): """ Returns the current and latest version of the application. |