diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-01 17:48:57 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-01 17:48:57 +0100 |
commit | c617b18d12c2f9d82ce7c73aae46d353b83f625a (patch) | |
tree | 898f5090865a8aea64fb87e56f9ebfc979a6b706 /g4f/debug.py | |
parent | Patch event loop on win, Check event loop closed (diff) | |
download | gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.tar gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.tar.gz gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.tar.bz2 gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.tar.lz gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.tar.xz gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.tar.zst gpt4free-c617b18d12c2f9d82ce7c73aae46d353b83f625a.zip |
Diffstat (limited to 'g4f/debug.py')
-rw-r--r-- | g4f/debug.py | 48 |
1 files changed, 4 insertions, 44 deletions
diff --git a/g4f/debug.py b/g4f/debug.py index 9d2f40ed..68a4f1ec 100644 --- a/g4f/debug.py +++ b/g4f/debug.py @@ -1,45 +1,5 @@ -from os import environ -import requests -from importlib.metadata import version as get_package_version, PackageNotFoundError -from subprocess import check_output, CalledProcessError, PIPE -from .errors import VersionNotFoundError +from .base_provider import ProviderType -logging = False -version_check = True - -def get_version() -> str: - # Read from package manager - try: - return get_package_version("g4f") - except PackageNotFoundError: - pass - # Read from docker environment - current_version = environ.get("G4F_VERSION") - if current_version: - return current_version - # Read from git repository - try: - command = ["git", "describe", "--tags", "--abbrev=0"] - return check_output(command, text=True, stderr=PIPE).strip() - except CalledProcessError: - pass - raise VersionNotFoundError("Version not found") - -def get_latest_version() -> str: - 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: - try: - version = get_version() - latest_version = get_latest_version() - if version != latest_version: - print(f'New pypi version: {latest_version} (current: {version}) | pip install -U g4f') - except Exception as e: - print(f'Failed to check g4f pypi version: {e}')
\ No newline at end of file +logging: bool = False +version_check: bool = True +last_provider: ProviderType = None
\ No newline at end of file |