group create new file upon first opening program

pull/3/head
sean1832 1 year ago
parent d1b15d09f3
commit c4c41e054a

@ -1,5 +1,6 @@
import streamlit as st
from modules import utilities as util
import initial_file_creator
import brain
import check_update
import time
@ -20,6 +21,9 @@ LOG_PATH = '.user/log'
SESSION_TIME = st.session_state['SESSION_TIME']
CURRENT_LOG_FILE = f'{LOG_PATH}/log_{SESSION_TIME}.log'
# create necessary files
initial_file_creator.create()
def create_log():
if not os.path.exists(CURRENT_LOG_FILE):

@ -0,0 +1,12 @@
import os
from modules import utilities as util
user_dir = r'.user'
def create():
# create brain data
util.create_json_not_exist(f'{user_dir}/brain-data.json')
# create brain memo
util.create_json_not_exist(f'{user_dir}/brain-memo.json',
{'note_dir': '', 'delimiter': '', 'append_mode': 'False', 'force_mode': 'False'})

@ -26,14 +26,16 @@ def save(content, path, page=''):
util.update_json(brain_memo, 'append_mode', append_mode)
util.update_json(brain_memo, 'force_mode', force_delimiter)
def select_directory():
root = tk.Tk()
root.withdraw()
# make sure the dialoge is on top of the main window
# make sure the dialog is on top of the main window
root.attributes('-topmost', True)
directory = filedialog.askdirectory(initialdir=os.getcwd(), title='Select Note Directory', master=root)
return directory
with st.sidebar:
st.title('Settings')
menu = st.radio('Menu', [
@ -49,7 +51,7 @@ with body:
st.text('Configuration of prompts.')
selected_file = st.selectbox('Prompt File', os.listdir(prompt_dir))
selected_path = prompt_dir + selected_file
mod_text = st.text_area('Prompts',value=util.read_file(selected_path), height=500)
mod_text = st.text_area('Prompts', value=util.read_file(selected_path), height=500)
save(mod_text, selected_path)
case '💽Brain Memory':
@ -59,10 +61,6 @@ with body:
note_dir = ''
util.create_json_not_exist(brain_memo, {'note_dir': '', 'delimiter': '', 'append_mode': 'False', 'force_mode': 'False'})
util.create_file_not_exist(f'{user_dir}note_dir_info.txt')
util.create_file_not_exist(f'{user_dir}brain_mem_sig.temp')
col1, col2 = st.columns(2)
with col1:
st.button('🔄Refresh')
@ -70,22 +68,22 @@ with body:
if st.button('📁Select Note Directory'):
note_dir = select_directory()
util.update_json(brain_memo, 'note_dir', note_dir)
note_dir = st.text_input('Note Directory', value=util.read_json_at(brain_memo, 'note_dir'), placeholder='Select Note Directory', key='note_dir')
note_dir = st.text_input('Note Directory', value=util.read_json_at(brain_memo, 'note_dir'),
placeholder='Select Note Directory', key='note_dir')
col1, col2 = st.columns(2)
with col1:
delimiter_memo = util.read_json_at(brain_memo, 'delimiter')
delimiter = st.text_input('Delimiter', delimiter_memo, placeholder='e.g. +++')
with col2:
append_mode = st.checkbox('Append Mode', value=util.read_json_at(brain_memo, 'append_mode'))
force_delimiter = st.checkbox('Force Delimiter', value=util.read_json_at(brain_memo, 'force_mode'))
# if note directory is selected
if note_dir != '':
note_data = util.read_files(note_dir, delimiter, force_delimiter)
if append_mode:
memory_data += note_data
@ -109,5 +107,3 @@ with body:
st.text('Configure your OpenAI API keys.')
mod_text = st.text_input('API Keys', value=util.read_file(f'{user_dir}API-KEYS.txt'))
save(mod_text, f'{user_dir}API-KEYS.txt')

Loading…
Cancel
Save