Skip to content

Commit 35b2927

Browse files
authored
fix: update app version resolver in flowsettings (#180) (bump:patch)
1 parent 4d5f9ba commit 35b2927

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

flowsettings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
# change this if your app use a different name
1616
KH_PACKAGE_NAME = "kotaemon_app"
1717

18-
KH_APP_VERSION = config("KH_APP_VERSION", "local")
18+
KH_APP_VERSION = config("KH_APP_VERSION", None)
1919
if not KH_APP_VERSION:
2020
try:
2121
# Caution: This might produce the wrong version
2222
# https://stackoverflow.com/a/59533071
2323
KH_APP_VERSION = version(KH_PACKAGE_NAME)
24-
except Exception as e:
25-
print(f"Failed to get app version: {e}")
24+
except Exception:
25+
KH_APP_VERSION = "local"
2626

2727
# App can be ran from anywhere and it's not trivial to decide where to store app data.
2828
# So let's use the same directory as the flowsetting.py file.

libs/ktem/ktem/assets/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
from decouple import config
44

55
PDFJS_VERSION_DIST: str = config("PDFJS_VERSION_DIST", "pdfjs-4.0.379-dist")
6-
PDFJS_PREBUILT_DIR: Path = Path(__file__).parent / "prebuilt" / PDFJS_VERSION_DIST
6+
PDFJS_PREBUILT_DIR: Path = config(
7+
"PDFJS_PREBUILT_DIR", Path(__file__).parent / "prebuilt" / PDFJS_VERSION_DIST
8+
)

scripts/run_linux.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ function download_and_unzip() {
170170
}
171171

172172
function launch_ui() {
173-
python $(pwd)/app.py || {
173+
local pdfjs_prebuilt_dir=$1
174+
PDFJS_PREBUILT_DIR="$pdfjs_prebuilt_dir" python $(pwd)/app.py || {
174175
echo "" && echo "Will exit now..."
175176
exit 1
176177
}
@@ -217,7 +218,7 @@ print_highlight "Setting up a local model"
217218
setup_local_model
218219

219220
print_highlight "Launching Kotaemon in your browser, please wait..."
220-
launch_ui
221+
launch_ui $target_pdf_js_dir
221222

222223
deactivate_conda_env
223224

scripts/run_macos.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Functions for better code organization
3+
# functions for better code organization
44
function check_path_for_spaces() {
55
if [[ $PWD =~ \ ]]; then
66
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() {
171171
}
172172

173173
function launch_ui() {
174-
python $(pwd)/app.py || {
174+
local pdfjs_prebuilt_dir=$1
175+
PDFJS_PREBUILT_DIR="$pdfjs_prebuilt_dir" python $(pwd)/app.py || {
175176
echo "" && echo "Will exit now..."
176177
exit 1
177178
}
@@ -221,7 +222,7 @@ print_highlight "Setting up a local model"
221222
setup_local_model
222223

223224
print_highlight "Launching Kotaemon in your browser, please wait..."
224-
launch_ui
225+
launch_ui $target_pdf_js_dir
225226

226227
deactivate_conda_env
227228

0 commit comments

Comments
 (0)