summaryrefslogtreecommitdiffstats
path: root/g4f/version.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-13 15:37:36 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-13 15:37:36 +0100
commitea8d6b847a0e656cc5583948c5745592adda7103 (patch)
treecb796ff258d339a5ee4a4ec3fb4b2617e6639677 /g4f/version.py
parentChange pypi to live (diff)
downloadgpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar
gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.gz
gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.bz2
gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.lz
gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.xz
gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.zst
gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.zip
Diffstat (limited to 'g4f/version.py')
-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