Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
code/embeddings_text.csv
code/utilities/__pycache__
.env
__pycache__
__pycache__
backuppage
70 changes: 0 additions & 70 deletions code/OpenAI_Queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def get_languages():
st.set_page_config(layout="wide", menu_items=menu_items)

llm_helper = LLMHelper(custom_prompt=st.session_state.custom_prompt, temperature=st.session_state.custom_temperature)

# Get available languages for translation
available_languages = get_languages()

Expand All @@ -166,74 +165,5 @@ def get_languages():
col1, col2, col3 = st.columns([2,2,2])
with col1:
st.button("Check deployment", on_click=check_deployment)
with col3:
with st.expander("Settings"):
# model = st.selectbox(
# "OpenAI GPT-3 Model",
# [os.environ['OPENAI_ENGINE']]
# )
# st.tokens_response = st.slider("Tokens response length", 100, 500, 400)
st.slider("Temperature", min_value=0.0, max_value=1.0, step=0.1, key='custom_temperature')
st.text_area("Custom Prompt", key='custom_prompt', on_change=check_variables_in_prompt, placeholder= custom_prompt_placeholder,help=custom_prompt_help, height=150)
st.selectbox("Language", [None] + list(available_languages.keys()), key='translation_language')


question = st.text_input("Azure OpenAI Semantic Answer", value=st.session_state['askedquestion'], key="input"+str(st.session_state ['input_message_key']), on_change=questionAsked)

# Answer the question if any
if st.session_state.askedquestion != '':
st.session_state['question'] = st.session_state.askedquestion
st.session_state.askedquestion = ""
st.session_state['question'], \
st.session_state['response'], \
st.session_state['context'], \
st.session_state['sources'] = llm_helper.get_semantic_answer_lang_chain(st.session_state['question'], [])
st.session_state['response'], followup_questions_list = llm_helper.extract_followupquestions(st.session_state['response'])
st.session_state['followup_questions'] = followup_questions_list

sourceList = []

# Display the sources and context - even if the page is reloaded
if st.session_state['sources'] or st.session_state['context']:
st.session_state['response'], sourceList, matchedSourcesList, linkList, filenameList = llm_helper.get_links_filenames(st.session_state['response'], st.session_state['sources'])
st.write("<br>", unsafe_allow_html=True)
st.markdown("Answer: " + st.session_state['response'])

# Display proposed follow-up questions which can be clicked on to ask that question automatically
if len(st.session_state['followup_questions']) > 0:
st.write("<br>", unsafe_allow_html=True)
st.markdown('**Proposed follow-up questions:**')
with st.container():
for questionId, followup_question in enumerate(st.session_state['followup_questions']):
if followup_question:
str_followup_question = re.sub(r"(^|[^\\\\])'", r"\1\\'", followup_question)
st.button(str_followup_question, key=1000+questionId, on_click=ask_followup_question, args=(followup_question, ))

if st.session_state['sources'] or st.session_state['context']:
# Buttons to display the context used to answer
st.write("<br>", unsafe_allow_html=True)
st.markdown('**Document sources:**')
for id in range(len(sourceList)):
st.markdown(f"[{id+1}] {sourceList[id]}")

# Details on the question and answer context
st.write("<br><br>", unsafe_allow_html=True)
with st.expander("Question and Answer Context"):
if not st.session_state['context'] is None and st.session_state['context'] != []:
for content_source in st.session_state['context'].keys():
st.markdown(f"#### {content_source}")
for context_text in st.session_state['context'][content_source]:
st.markdown(f"{context_text}")

st.markdown(f"SOURCES: {st.session_state['sources']}")

for questionId, followup_question in enumerate(st.session_state['followup_questions']):
if followup_question:
str_followup_question = re.sub(r"(^|[^\\\\])'", r"\1\\'", followup_question)

if st.session_state['translation_language'] and st.session_state['translation_language'] != '':
st.write(f"Translation to other languages, 翻译成其他语言, النص باللغة العربية")
st.write(f"{llm_helper.translator.translate(st.session_state['response'], available_languages[st.session_state['translation_language']])}")

except Exception:
st.error(traceback.format_exc())
95 changes: 0 additions & 95 deletions code/pages/00_Chat.py

This file was deleted.

143 changes: 0 additions & 143 deletions code/pages/01_Add_Document.py

This file was deleted.

Loading