From 80957acc7221985f2178f546534c5c72cd697b57 Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:26:04 +1100 Subject: [PATCH 1/7] chore: remove unused module --- Seanium_Brain.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Seanium_Brain.py b/Seanium_Brain.py index 019e733..9b535f4 100644 --- a/Seanium_Brain.py +++ b/Seanium_Brain.py @@ -1,5 +1,4 @@ import os -import time import streamlit as st import streamlit_toggle as st_toggle From 1e0acb459abe220bb45d836d165b8a0ab2c3ba4a Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:30:16 +1100 Subject: [PATCH 2/7] fix: change default stream mode to false --- Seanium_Brain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Seanium_Brain.py b/Seanium_Brain.py index 9b535f4..99b17a5 100644 --- a/Seanium_Brain.py +++ b/Seanium_Brain.py @@ -91,7 +91,7 @@ with st.sidebar: "will it be.")) enable_stream = st_toggle.st_toggle_switch(_('Stream (experimental)'), default_value=util.read_json_at(INFO.BRAIN_MEMO, 'enable_stream', - True)) + False)) if not enable_stream: chunk_count = st.slider(_('Answer count'), 1, 5, value=util.read_json_at(INFO.BRAIN_MEMO, 'chunk_count', 1), From 250e3b33778ec1d649a631ed9eb33d1423c9da66 Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:48:34 +1100 Subject: [PATCH 3/7] 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): From 044b4c2e389699ab8c750228df94a70b2eda2600 Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:49:31 +1100 Subject: [PATCH 4/7] chore: remove unused code --- pages/1_Configs.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pages/1_Configs.py b/pages/1_Configs.py index 45eec43..7f1a5a4 100644 --- a/pages/1_Configs.py +++ b/pages/1_Configs.py @@ -14,10 +14,6 @@ PROMPT_PATH = f'{INFO.USER_DIR}/prompt/{SESSION_LANG}/' _ = language.set_language() -# st.set_page_config( -# page_title='Configs' -# ) - body = st.container() From 4590d6846594f6f894ec22c0e0b6d9ae3484bdb4 Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:53:56 +1100 Subject: [PATCH 5/7] ui: move chunk size out of advanced options --- Seanium_Brain.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Seanium_Brain.py b/Seanium_Brain.py index 99b17a5..d1e08ca 100644 --- a/Seanium_Brain.py +++ b/Seanium_Brain.py @@ -64,6 +64,11 @@ with st.sidebar: "your prompt plus `max_tokens` cannot exceed the model's context length. Most " "models have a context length of 2048 tokens (except for the newest models, " "which support 4096).")) + chunk_size = st.slider(_('Chunk size'), 1500, 4500, + value=util.read_json_at(INFO.BRAIN_MEMO, 'chunk_size', 4000), + help=_("The number of tokens to consider at each step. The larger this is, the more " + "context the model has to work with, but the slower generation and expensive " + "will it be.")) with st.expander(label=_('Advanced Options')): top_p = st.slider(_('Top_P'), 0.0, 1.0, value=util.read_json_at(INFO.BRAIN_MEMO, 'top_p', 1.0), @@ -83,12 +88,6 @@ with st.sidebar: "new tokens based on their existing frequency in the text so far." "\n\n[See more information about frequency and presence penalties.]" "(https://platform.openai.com/docs/api-reference/parameter-details)")) - - chunk_size = st.slider(_('Chunk size'), 1500, 4500, - value=util.read_json_at(INFO.BRAIN_MEMO, 'chunk_size', 4000), - help=_("The number of tokens to consider at each step. The larger this is, the more " - "context the model has to work with, but the slower generation and expensive " - "will it be.")) enable_stream = st_toggle.st_toggle_switch(_('Stream (experimental)'), default_value=util.read_json_at(INFO.BRAIN_MEMO, 'enable_stream', False)) From e6a122bfc5777985ec409d3d31bf29eeb9d7701d Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:58:07 +1100 Subject: [PATCH 6/7] feat: adjust max token minimum number --- Seanium_Brain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Seanium_Brain.py b/Seanium_Brain.py index d1e08ca..e0533e6 100644 --- a/Seanium_Brain.py +++ b/Seanium_Brain.py @@ -59,7 +59,7 @@ with st.sidebar: help=_('What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the ' 'output more random, while lower values like 0.2 will make it more focused and ' 'deterministic. \n\nIt is generally recommend altering this or `top_p` but not both.')) - max_tokens = st.slider(_('Max Tokens'), 850, 4096, value=util.read_json_at(INFO.BRAIN_MEMO, 'max_tokens', 1000), + max_tokens = st.slider(_('Max Tokens'), 10, 4096, value=util.read_json_at(INFO.BRAIN_MEMO, 'max_tokens', 1000), help=_("The maximum number of tokens to generate in the completion.\n\nThe token count of " "your prompt plus `max_tokens` cannot exceed the model's context length. Most " "models have a context length of 2048 tokens (except for the newest models, " From aaea6a84d3dc6ae35ea05b1582923aa0d5e2ec38 Mon Sep 17 00:00:00 2001 From: sean1832 Date: Sat, 25 Feb 2023 15:59:11 +1100 Subject: [PATCH 7/7] chore: remove unused code --- streamlit_toolkit/tools.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/streamlit_toolkit/tools.py b/streamlit_toolkit/tools.py index 77a0c6a..5d4a7c2 100644 --- a/streamlit_toolkit/tools.py +++ b/streamlit_toolkit/tools.py @@ -62,15 +62,7 @@ def save(content, path, page='', json_value: dict = None): if page == '💽Brain Memory': for key, value in json_value.items(): util.update_json(INFO.BRAIN_MEMO, key, value) - # - # - # util.update_json(INFO.BRAIN_MEMO, 'delimiter', json_value['delimiter']) - # util.update_json(INFO.BRAIN_MEMO, 'append_mode', json_value['append_mode']) - # util.update_json(INFO.BRAIN_MEMO, 'force_mode', json_value['force_mode']) - # util.update_json(INFO.BRAIN_MEMO, 'advanced_mode', json_value['advanced_mode']) - # util.update_json(INFO.BRAIN_MEMO, 'filter_info', json_value['filter_info']) - # util.update_json(INFO.BRAIN_MEMO, 'filter_row_count', json_value['filter_row_count']) - # util.update_json(INFO.BRAIN_MEMO, 'exclude_dir', json_value['exclude_dir']) + time.sleep(1) # refresh page st.experimental_rerun()