fix bug: does not generate text first time setting up app

pull/3/head
sean1832 1 year ago
parent 1c3ab7ea1b
commit 80673cb2c4

@ -14,8 +14,6 @@ st.set_page_config(
page_title='Seanium Brain'
)
model_options = ['text-davinci-003', 'text-curie-001', 'text-babbage-001', 'text-ada-001']
header = st.container()
body = st.container()
@ -24,8 +22,6 @@ SESSION_TIME = st.session_state['SESSION_TIME']
CURRENT_LOG_FILE = f'{LOG_PATH}/log_{SESSION_TIME}.log'
def create_log():
if not os.path.exists(CURRENT_LOG_FILE):
util.write_file(f'Session {SESSION_TIME}\n\n', CURRENT_LOG_FILE)
@ -89,6 +85,7 @@ def execute_brain(q):
# log question
log(f'\n\n\n\n[{str(time.ctime())}] - QUESTION: {q}')
print(f'update: {check_update.isUpdated()}')
if check_update.isUpdated():
# if brain-info is updated
brain.build(chunk_size)

@ -21,6 +21,7 @@ def build(chunk_size=4000):
result = []
print('Building brain data...')
for chunk in chunks:
embedding = gpt.embedding(chunk.encode(encoding='ASCII', errors='ignore').decode())
info = {'content': chunk, 'vector': embedding}

@ -31,6 +31,7 @@ def isUpdated():
print('Temp file not exist, writing temp file...')
# write to temp file
util.write_file(read_mod_time, temp_file)
return False
time.sleep(1)
return True
else:
raise FileNotFoundError(f'File: {file_path} does not exist.')

Loading…
Cancel
Save