From 250e3b33778ec1d649a631ed9eb33d1423c9da66 Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:48:34 +1100 Subject: [PATCH] fix: adjust chunk size does not update brain --- modules/check_update.py | 9 ++++++++- streamlit_toolkit/tools.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/check_update.py b/modules/check_update.py index f3c3d70..ddad5f2 100644 --- a/modules/check_update.py +++ b/modules/check_update.py @@ -1,6 +1,7 @@ import os import time import modules.utilities as util +import modules as mod file_path = r'.user\input.txt' temp_file = r'.user\input_last-run.temp' @@ -10,7 +11,7 @@ def compare_time(t1, t2): return t1 == t2 -def isUpdated(): +def is_input_updated(): if os.path.exists(file_path): # get modification time of the file mod_time = os.path.getmtime(file_path) @@ -35,3 +36,9 @@ def isUpdated(): return True else: raise FileNotFoundError(f'File: {file_path} does not exist.') + + +def is_param_updated(param_val, param_infile_key): + infile_val = util.read_json_at(mod.INFO.BRAIN_MEMO, param_infile_key) + if infile_val != param_val: + return True diff --git a/streamlit_toolkit/tools.py b/streamlit_toolkit/tools.py index fac7c03..77a0c6a 100644 --- a/streamlit_toolkit/tools.py +++ b/streamlit_toolkit/tools.py @@ -270,7 +270,7 @@ def execute_brain(q, params: GPT.model.param, # log question log(f'\n\n\n\n[{str(time.ctime())}] - QUESTION: {q}') - if mod.check_update.isUpdated(): + if mod.check_update.is_input_updated() or mod.check_update.is_param_updated(params.chunk_size, 'chunk_size'): msg = st.warning(_('Updating Brain...'), icon="⏳") progress_bar = st.progress(0) for idx, chunk_num in GPT.query.build(params.chunk_size):