BREAKING CHANGE: add support for multilingual search

pull/6/head
sean1832 1 year ago
parent 1c5e643a16
commit f3f658b9fe

@ -15,7 +15,7 @@ if 'SESSION_LANGUAGE' not in st.session_state:
st.session_state['SESSION_LANGUAGE'] = util.read_json_at('.user/language.json', 'SESSION_LANGUAGE', 'en_US')
st.set_page_config(
page_title='Seanium Brain'
page_title='GPT Brain'
)
util.remove_oldest_file('.user/log', 10)
@ -24,8 +24,9 @@ model_options = ['text-davinci-003', 'text-curie-001', 'text-babbage-001', 'text
header = st.container()
body = st.container()
LOG_PATH = '.user/log'
PROMPT_PATH = '.user/prompt'
SESSION_TIME = st.session_state['SESSION_TIME']
SESSION_LANG = st.session_state['SESSION_LANGUAGE']
PROMPT_PATH = f'.user/prompt/{SESSION_LANG}'
CURRENT_LOG_FILE = f'{LOG_PATH}/log_{SESSION_TIME}.log'
BRAIN_MEMO = '.user/brain-memo.json'
MANIFEST = '.core/manifest.json'
@ -102,11 +103,11 @@ with st.sidebar:
prompt_file_names = [util.get_file_name(file) for file in prompt_files]
prompt_dictionary = dict(zip(prompt_file_names, prompt_files))
# remove 'my-info' from prompt dictionary
prompt_dictionary.pop('my-info')
prompt_dictionary.pop(_('my-info'))
operation_options = list(prompt_dictionary.keys())
operations = st.multiselect(_('Operations'), operation_options, default=util.read_json_at(BRAIN_MEMO, 'operations',
print(util.read_json_at(BRAIN_MEMO, f'operations_{SESSION_LANG}', operation_options[0]))
operations = st.multiselect(_('Operations'), operation_options, default=util.read_json_at(BRAIN_MEMO, f'operations_{SESSION_LANG}',
operation_options[0]))
last_question_model = util.read_json_at(BRAIN_MEMO, 'question_model', model_options[0])
@ -114,7 +115,7 @@ with st.sidebar:
question_model_index = util.get_index(model_options, last_question_model)
question_model = st.selectbox(_('Question Model'), model_options, index=question_model_index)
operations_no_question = [op for op in operations if op != 'question']
operations_no_question = [op for op in operations if op != _('question')]
other_models = []
replace_tokens = []
for operation in operations_no_question:
@ -182,7 +183,7 @@ def execute_brain(q):
with st.spinner(_('Thinking on Answer')):
answer = brain.run_answer(q, question_model, temp, max_tokens, top_p, freq_panl, pres_panl,
chunk_count=chunk_count)
if util.contains(operations, 'question'):
if util.contains(operations, _('question')):
# displaying results
st.header(_('💬Answer'))
st.info(f'{answer}')
@ -204,7 +205,7 @@ def execute_brain(q):
util.update_json(BRAIN_MEMO, key, value)
# write operation to json
util.update_json(BRAIN_MEMO, 'operations', operations)
util.update_json(BRAIN_MEMO, f'operations_{SESSION_LANG}', operations)
# write question model to json
util.update_json(BRAIN_MEMO, 'question_model', question_model)

@ -0,0 +1,5 @@
为以下文章总结成清晰易读的要点, 注意包含所有的重要信息。
<<DATA>>
要点:

@ -0,0 +1 @@
我的名字是肖恩,我是一名建筑学学生。

@ -0,0 +1,4 @@
根据 <<MY-INFO>> 的前提, 通过以下信息: <<INFO>> , 以一个建筑师的角度回答问题: <<QS>> 并给予答案, 要求答案文笔清晰,能够容易的阅读,并且避免重复的内容。
确保答案包含所有关键的内容。
答案:

@ -112,8 +112,8 @@ def create_json_not_exist(filepath, initial_value={}):
write_json(initial_value, filepath)
def write_json(content, filepath, mode='w'):
with open(filepath, mode) as file:
def write_json(content, filepath, mode='w', encoding='UTF-8'):
with open(filepath, mode, encoding=encoding) as file:
json.dump(content, file, indent=2)

@ -23,9 +23,12 @@ REM if .user\ not exist, create one
if not exist .user\ (md .user\)
REM Create API KEY file
set /p API_KEYS=[Enter your API keys]:
echo %API_KEYS%> .user\API-KEYS.txt
echo API key written to file!
if not exist .user\API-KEYS.txt (
set /p API_KEYS=[Enter your API keys]:
echo %API_KEYS%> .user\API-KEYS.txt
echo API key written to file!
)
REM copy example prompt
if not exist .user\prompt (md .user\prompt)
@ -35,8 +38,11 @@ REM wait 2 tick
ping 127.0.0.1 -n 2 > NUL
REM create input txt file
echo.> .user\input.txt
echo input file created!
if not exist .user\input.txt (
echo.> .user\input.txt
echo input file created!
)
python web_ui/initial_file_creator.py

Loading…
Cancel
Save