mohcineelharras commited on
Commit
f35f223
β€’
1 Parent(s): 77b04d1

added reinit button for query_engine, session state as well

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -166,12 +166,22 @@ with st.sidebar:
166
  st.subheader("Developer Information:")
167
  st.write("This app is developed and maintained by **@mohcineelharras**")
168
 
169
- # Define your app's tabs
170
- tab1, tab2, tab3 = st.tabs(["LLM only", "LLM RAG QA with database", "One single document Q&A"])
171
  if 'memory' not in st.session_state:
172
  st.session_state.memory = ""
173
- llm = load_llm_model()
174
- query_engine = load_emb_model()
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  # -----------------------------------LLM only---------------------------------------------
177
 
@@ -222,6 +232,9 @@ with tab2:
222
 
223
  with tab3:
224
  st.title("πŸ“ One single document Q&A with Llama Index using local open llms")
 
 
 
225
  uploaded_file = st.file_uploader("Upload an File", type=("txt", "csv", "md","pdf"))
226
  question = st.text_input(
227
  "Ask something about the files",
 
166
  st.subheader("Developer Information:")
167
  st.write("This app is developed and maintained by **@mohcineelharras**")
168
 
 
 
169
  if 'memory' not in st.session_state:
170
  st.session_state.memory = ""
171
+ # LLM Model Loading
172
+ if 'llm_model' not in st.session_state:
173
+ st.session_state.llm_model = load_llm_model()
174
+
175
+ # Embedding Model Loading
176
+ if 'emb_model' not in st.session_state:
177
+ st.session_state.emb_model = load_emb_model()
178
+
179
+ # Use the models from session state
180
+ llm = st.session_state.llm_model
181
+ query_engine = st.session_state.emb_model
182
+
183
+ # Define your app's tabs
184
+ tab1, tab2, tab3 = st.tabs(["LLM only", "LLM RAG QA with database", "One single document Q&A"])
185
 
186
  # -----------------------------------LLM only---------------------------------------------
187
 
 
232
 
233
  with tab3:
234
  st.title("πŸ“ One single document Q&A with Llama Index using local open llms")
235
+ if st.button('Reinitialize Query Engine', key='reinit_engine'):
236
+ query_engine = st.session_state.emb_model
237
+ st.write("Query engine reinitialized.")
238
  uploaded_file = st.file_uploader("Upload an File", type=("txt", "csv", "md","pdf"))
239
  question = st.text_input(
240
  "Ask something about the files",