diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-11-23 10:02:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-23 10:02:30 +0100 |
commit | 538c0bb2c4a1ec91bdde849b6256087ac0adfcd9 (patch) | |
tree | 4b2d4d11c3e311d1eb74337311b1ce04a5cb37b8 /g4f | |
parent | Update setup.py (diff) | |
download | gpt4free-0.3.6.3.tar gpt4free-0.3.6.3.tar.gz gpt4free-0.3.6.3.tar.bz2 gpt4free-0.3.6.3.tar.lz gpt4free-0.3.6.3.tar.xz gpt4free-0.3.6.3.tar.zst gpt4free-0.3.6.3.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/api/__init__.py | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index 628d7512..f67a2aea 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -360,39 +360,7 @@ class Api: return FileResponse(target, media_type=content_type) - @self.app.get("/providers") - async def providers(): - model_list = [{ - 'id': provider.__name__, - 'object': 'provider', - 'created': 0, - 'url': provider.url, - 'label': getattr(provider, "label", None), - } for provider in __providers__ if provider.working] - return JSONResponse(model_list) - - @self.app.get("/providers/{provider}") - async def providers_info(provider: str): - if provider not in ProviderUtils.convert: - return JSONResponse({"error": "The model does not exist."}, 404) - provider: ProviderType = ProviderUtils.convert[provider] - def safe_get_models(provider: ProviderType) -> list[str]: - try: - return provider.get_models() if hasattr(provider, "get_models") else [] - except: - return [] - provider_info = { - 'id': provider.__name__, - 'object': 'provider', - 'created': 0, - 'url': provider.url, - 'label': getattr(provider, "label", None), - 'models': safe_get_models(provider), - 'image_models': getattr(provider, "image_models", []) or [], - 'vision_models': [model for model in [getattr(provider, "default_vision_model", None)] if model], - 'params': [*provider.get_parameters()] if hasattr(provider, "get_parameters") else [] - } - return JSONResponse(provider_info) + def format_exception(e: Exception, config: Union[ChatCompletionsConfig, ImageGenerationConfig], image: bool = False) -> str: last_provider = {} if not image else g4f.get_last_provider(True) |