summaryrefslogtreecommitdiffstats
path: root/g4f/version.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-13 15:52:52 +0100
committerGitHub <noreply@github.com>2024-01-13 15:52:52 +0100
commitd632190f1d9ff04759a427d1938c0813e918e5e8 (patch)
tree44e3827128489f13fd6fbe7d18171d81176abc86 /g4f/version.py
parentCleanup unused dependencies (diff)
parentMerge pull request #1462 from hlohaus/img (diff)
downloadgpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.tar
gpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.tar.gz
gpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.tar.bz2
gpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.tar.lz
gpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.tar.xz
gpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.tar.zst
gpt4free-d632190f1d9ff04759a427d1938c0813e918e5e8.zip
Diffstat (limited to '')
-rw-r--r--g4f/version.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/g4f/version.py b/g4f/version.py
index 44d14369..bb4b7f17 100644
--- a/g4f/version.py
+++ b/g4f/version.py
@@ -5,6 +5,15 @@ from importlib.metadata import version as get_package_version, PackageNotFoundEr
from subprocess import check_output, CalledProcessError, PIPE
from .errors import VersionNotFoundError
+def get_latest_version() -> str:
+ try:
+ get_package_version("g4f")
+ response = requests.get("https://pypi.org/pypi/g4f/json").json()
+ return response["info"]["version"]
+ except PackageNotFoundError:
+ url = "https://api.github.com/repos/xtekky/gpt4free/releases/latest"
+ response = requests.get(url).json()
+ return response["tag_name"]
class VersionUtils():
@cached_property
@@ -28,20 +37,13 @@ class VersionUtils():
@cached_property
def latest_version(self) -> str:
- try:
- get_package_version("g4f")
- response = requests.get("https://pypi.org/pypi/g4f/json").json()
- return response["info"]["version"]
- except PackageNotFoundError:
- url = "https://api.github.com/repos/xtekky/gpt4free/releases/latest"
- response = requests.get(url).json()
- return response["tag_name"]
-
- def check_pypi_version(self) -> None:
+ return get_latest_version()
+
+ def check_version(self) -> None:
try:
if self.current_version != self.latest_version:
- print(f'New pypi version: {self.latest_version} (current: {self.current_version}) | pip install -U g4f')
+ print(f'New g4f version: {self.latest_version} (current: {self.current_version}) | pip install -U g4f')
except Exception as e:
- print(f'Failed to check g4f pypi version: {e}')
+ print(f'Failed to check g4f version: {e}')
utils = VersionUtils() \ No newline at end of file