taaha3244 commited on
Commit
27e2e36
1 Parent(s): 507bba8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -29
app.py CHANGED
@@ -21,14 +21,6 @@ def main():
21
  if 'uploaded_collection_name' not in st.session_state:
22
  st.session_state['uploaded_collection_name'] = None
23
 
24
- # Initialize session state for storing answers if not already set
25
- if 'data_bank_answer' not in st.session_state:
26
- st.session_state['data_bank_answer'] = None
27
- if 'uploaded_docs_answer' not in st.session_state:
28
- st.session_state['uploaded_docs_answer'] = None
29
- if 'voo_answer' not in st.session_state:
30
- st.session_state['voo_answer'] = None
31
-
32
  if uploaded_files:
33
  if st.sidebar.button("Add Docs to Data Bank"):
34
  files_info = save_uploaded_files(uploaded_files)
@@ -93,15 +85,10 @@ def page_qna(uploaded_files):
93
  user_query = st.text_area("Enter your question here:", height=300)
94
  if st.button('Get Answer'):
95
  if user_query:
96
- if 'data_bank_answer' not in st.session_state or st.session_state['data_bank_answer'] is None:
97
- answer = handle_query(user_query)
98
- st.session_state['data_bank_answer'] = answer # Store the answer in session state
99
- st.write(st.session_state['data_bank_answer'])
100
  else:
101
  st.error("Please enter a question to get an answer.")
102
- # Display stored answer if it exists
103
- if st.session_state['data_bank_answer']:
104
- st.write(st.session_state['data_bank_answer'])
105
 
106
  def page_chat_with_uploaded_docs(uploaded_files):
107
  """Page for chatting with uploaded documents."""
@@ -109,15 +96,10 @@ def page_chat_with_uploaded_docs(uploaded_files):
109
  user_query = st.text_area("Enter your question here:", height=300)
110
  if st.button('Get Answer'):
111
  if user_query:
112
- if 'uploaded_docs_answer' not in st.session_state or st.session_state['uploaded_docs_answer'] is None:
113
- answer = handle_uploaded_docs_query(user_query, st.session_state['uploaded_collection_name'])
114
- st.session_state['uploaded_docs_answer'] = answer # Store the answer in session state
115
- st.write(st.session_state['uploaded_docs_answer'])
116
  else:
117
  st.error("Please enter a question to get an answer.")
118
- # Display stored answer if it exists
119
- if st.session_state['uploaded_docs_answer']:
120
- st.write(st.session_state['uploaded_docs_answer'])
121
 
122
  if st.session_state['uploaded_collection_name']:
123
  if st.button('Delete Embedded Collection'):
@@ -132,15 +114,10 @@ def page_chat_with_voo(uploaded_files):
132
  user_query = st.text_area("Enter your question here:", height=300)
133
  if st.button('Get Answer'):
134
  if user_query:
135
- if 'voo_answer' not in st.session_state or st.session_state['voo_answer'] is None:
136
- answer = handle_voo_query(user_query)
137
- st.session_state['voo_answer'] = answer # Store the answer in session state
138
- st.write(st.session_state['voo_answer'])
139
  else:
140
  st.error("Please enter a question to get an answer.")
141
- # Display stored answer if it exists
142
- if st.session_state['voo_answer']:
143
- st.write(st.session_state['voo_answer'])
144
 
145
  def embed_documents_to_data_bank(files_info):
146
  """Function to embed documents into the data bank."""
 
21
  if 'uploaded_collection_name' not in st.session_state:
22
  st.session_state['uploaded_collection_name'] = None
23
 
 
 
 
 
 
 
 
 
24
  if uploaded_files:
25
  if st.sidebar.button("Add Docs to Data Bank"):
26
  files_info = save_uploaded_files(uploaded_files)
 
85
  user_query = st.text_area("Enter your question here:", height=300)
86
  if st.button('Get Answer'):
87
  if user_query:
88
+ answer = handle_query(user_query)
89
+ st.write(answer)
 
 
90
  else:
91
  st.error("Please enter a question to get an answer.")
 
 
 
92
 
93
  def page_chat_with_uploaded_docs(uploaded_files):
94
  """Page for chatting with uploaded documents."""
 
96
  user_query = st.text_area("Enter your question here:", height=300)
97
  if st.button('Get Answer'):
98
  if user_query:
99
+ answer = handle_uploaded_docs_query(user_query, st.session_state['uploaded_collection_name'])
100
+ st.write(answer)
 
 
101
  else:
102
  st.error("Please enter a question to get an answer.")
 
 
 
103
 
104
  if st.session_state['uploaded_collection_name']:
105
  if st.button('Delete Embedded Collection'):
 
114
  user_query = st.text_area("Enter your question here:", height=300)
115
  if st.button('Get Answer'):
116
  if user_query:
117
+ answer = handle_voo_query(user_query)
118
+ st.write(answer)
 
 
119
  else:
120
  st.error("Please enter a question to get an answer.")
 
 
 
121
 
122
  def embed_documents_to_data_bank(files_info):
123
  """Function to embed documents into the data bank."""