From 562a5c957997a1bb68a43b092664ac26c5c46c26 Mon Sep 17 00:00:00 2001 From: kqlio67 Date: Mon, 11 Nov 2024 19:57:35 +0200 Subject: feat(g4f/Provider/airforce/AirforceImage.py): Dynamically fetch image models from API --- g4f/Provider/airforce/AirforceImage.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'g4f') diff --git a/g4f/Provider/airforce/AirforceImage.py b/g4f/Provider/airforce/AirforceImage.py index 62d42b4f..b74bc364 100644 --- a/g4f/Provider/airforce/AirforceImage.py +++ b/g4f/Provider/airforce/AirforceImage.py @@ -3,6 +3,7 @@ from __future__ import annotations from aiohttp import ClientSession from urllib.parse import urlencode import random +import requests from ...typing import AsyncResult, Messages from ...image import ImageResponse @@ -16,20 +17,13 @@ class AirforceImage(AsyncGeneratorProvider, ProviderModelMixin): #working = True default_model = 'flux' - image_models = [ - 'flux', - 'flux-realism', - 'flux-anime', - 'flux-3d', - 'flux-disney', - 'flux-pixel', - 'flux-4o', - 'any-dark', - 'stable-diffusion-xl-base', - 'stable-diffusion-xl-lightning', - 'Flux-1.1-Pro', - ] - models = [*image_models] + + response = requests.get('https://api.airforce/imagine/models') + data = response.json() + + image_models = data + + models = [*image_models, "stable-diffusion-xl-base", "stable-diffusion-xl-lightning", "Flux-1.1-Pro"] model_aliases = { "sdxl": "stable-diffusion-xl-base", -- cgit v1.2.3