From f1ef23285ae6e63d5fb28f5e271fec0e40ad65f2 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 18 Nov 2024 15:41:45 +0100 Subject: Fix load model list i AirforceChat provider Add Microsoft Copilot provider Show image support in the model list of the gui --- g4f/Provider/needs_auth/OpenaiChat.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'g4f/Provider/needs_auth/OpenaiChat.py') diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py index 43444699..13e15f1d 100644 --- a/g4f/Provider/needs_auth/OpenaiChat.py +++ b/g4f/Provider/needs_auth/OpenaiChat.py @@ -6,6 +6,7 @@ import uuid import json import base64 import time +import requests from aiohttp import ClientWebSocketResponse from copy import copy @@ -62,13 +63,26 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin): supports_system_message = True default_model = "auto" default_vision_model = "gpt-4o" - models = ["auto", "gpt-4o-mini", "gpt-4o", "gpt-4", "gpt-4-gizmo"] + fallback_models = ["auto", "gpt-4", "gpt-4o", "gpt-4o-mini", "gpt-4o-canmore", "o1-preview", "o1-mini"] + vision_models = fallback_models _api_key: str = None _headers: dict = None _cookies: Cookies = None _expires: int = None + @classmethod + def get_models(cls): + if not cls.models: + try: + response = requests.get(f"{cls.url}/backend-anon/models") + response.raise_for_status() + data = response.json() + cls.models = [model.get("slug") for model in data.get("models")] + except Exception: + cls.models = cls.fallback_models + return cls.models + @classmethod async def create( cls, -- cgit v1.2.3