(bump:patch) Feat: Show app version in the Help page (#68)

* typo

* show version in the Help page

* update docs

* pump duckduckgo-search

* allow app version to be set by env var
This commit is contained in:
ian_Cin
2024-05-16 14:27:51 +07:00
committed by GitHub
parent bd34facddc
commit b2296cfcdf
5 changed files with 54 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
import os
from importlib.metadata import version
from inspect import currentframe, getframeinfo
from pathlib import Path
@@ -14,6 +15,15 @@ this_dir = Path(this_file).parent
# change this if your app use a different name
KH_PACKAGE_NAME = "kotaemon_app"
KH_APP_VERSION = os.environ.get("KH_APP_VERSION", None)
if not KH_APP_VERSION:
try:
# Caution: This might produce the wrong version
# https://stackoverflow.com/a/59533071
KH_APP_VERSION = version(KH_PACKAGE_NAME)
except Exception as e:
print(f"Failed to get app version: {e}")
# App can be ran from anywhere and it's not trivial to decide where to store app data.
# So let's use the same directory as the flowsetting.py file.
KH_APP_DATA_DIR = this_dir / "ktem_app_data"