From 5a7ce3a8abbaaea7e739d8802d73b6f23b57ecff Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sun, 24 Dec 2023 20:54:10 +0100 Subject: Update get_latest_version for docker --- g4f/debug.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'g4f') diff --git a/g4f/debug.py b/g4f/debug.py index 67664e5b..9d2f40ed 100644 --- a/g4f/debug.py +++ b/g4f/debug.py @@ -1,5 +1,5 @@ from os import environ -from requests import get +import requests from importlib.metadata import version as get_package_version, PackageNotFoundError from subprocess import check_output, CalledProcessError, PIPE from .errors import VersionNotFoundError @@ -26,7 +26,13 @@ def get_version() -> str: raise VersionNotFoundError("Version not found") def get_latest_version() -> str: - response = get("https://pypi.org/pypi/g4f/json").json() + if environ.get("G4F_VERSION"): + url = "https://registry.hub.docker.com/v2/repositories/" + url += "hlohaus789/g4f" + url += "/tags?page_size=2&ordering=last_updated" + response = requests.get(url).json() + return response["results"][1]["name"] + response = requests.get("https://pypi.org/pypi/g4f/json").json() return response["info"]["version"] def check_pypi_version() -> None: -- cgit v1.2.3