diff --git a/flowsettings.py b/flowsettings.py index 8eaba8b..4e6b14a 100644 --- a/flowsettings.py +++ b/flowsettings.py @@ -15,14 +15,14 @@ this_dir = Path(this_file).parent # change this if your app use a different name KH_PACKAGE_NAME = "kotaemon_app" -KH_APP_VERSION = config("KH_APP_VERSION", "local") +KH_APP_VERSION = config("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}") + except Exception: + KH_APP_VERSION = "local" # 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. diff --git a/libs/ktem/ktem/assets/__init__.py b/libs/ktem/ktem/assets/__init__.py index 8c0df2a..fd10eac 100644 --- a/libs/ktem/ktem/assets/__init__.py +++ b/libs/ktem/ktem/assets/__init__.py @@ -3,4 +3,6 @@ from pathlib import Path from decouple import config PDFJS_VERSION_DIST: str = config("PDFJS_VERSION_DIST", "pdfjs-4.0.379-dist") -PDFJS_PREBUILT_DIR: Path = Path(__file__).parent / "prebuilt" / PDFJS_VERSION_DIST +PDFJS_PREBUILT_DIR: Path = config( + "PDFJS_PREBUILT_DIR", Path(__file__).parent / "prebuilt" / PDFJS_VERSION_DIST +) diff --git a/scripts/run_linux.sh b/scripts/run_linux.sh index ec2f960..60528ab 100755 --- a/scripts/run_linux.sh +++ b/scripts/run_linux.sh @@ -170,7 +170,8 @@ function download_and_unzip() { } function launch_ui() { - python $(pwd)/app.py || { + local pdfjs_prebuilt_dir=$1 + PDFJS_PREBUILT_DIR="$pdfjs_prebuilt_dir" python $(pwd)/app.py || { echo "" && echo "Will exit now..." exit 1 } @@ -217,7 +218,7 @@ print_highlight "Setting up a local model" setup_local_model print_highlight "Launching Kotaemon in your browser, please wait..." -launch_ui +launch_ui $target_pdf_js_dir deactivate_conda_env diff --git a/scripts/run_macos.sh b/scripts/run_macos.sh index 5ba335b..6066fff 100755 --- a/scripts/run_macos.sh +++ b/scripts/run_macos.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Functions for better code organization +# functions for better code organization function check_path_for_spaces() { if [[ $PWD =~ \ ]]; then echo "The current workdir has whitespace which can lead to unintended behaviour. Please modify your path and continue later." @@ -171,7 +171,8 @@ function download_and_unzip() { } function launch_ui() { - python $(pwd)/app.py || { + local pdfjs_prebuilt_dir=$1 + PDFJS_PREBUILT_DIR="$pdfjs_prebuilt_dir" python $(pwd)/app.py || { echo "" && echo "Will exit now..." exit 1 } @@ -221,7 +222,7 @@ print_highlight "Setting up a local model" setup_local_model print_highlight "Launching Kotaemon in your browser, please wait..." -launch_ui +launch_ui $target_pdf_js_dir deactivate_conda_env