alibidaran commited on
Commit
c9bceab
·
verified ·
1 Parent(s): 12cd8a8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +28 -20
src/streamlit_app.py CHANGED
@@ -204,27 +204,35 @@ text=st.text_area("Ask your question:", height=100)
204
  document_button=st.pills("Ask based on Documents", ['search'], selection_mode="single")
205
  generate_button=st.button("Generate Response")
206
  if generate_button:
207
- if document_button:
208
- graph=load_graph(st.session_state.embeddings,st.session_state.chunks)
209
- graph=graph.compile()
210
- initial_state = {
211
- "embedded_query":embed_sentence(text),
212
- "knowledge": [],
213
- "summary": "",
214
- "final_response": None,}
215
- final_state = graph.invoke(initial_state)
216
- updated_text = f"""
217
- Then respond to the client. Also follow the retrived information in the ##Summary section.
218
- ## Instructions:
219
- {text}
220
- ## Summary:
221
- {final_state['summary']}
222
- """
223
- complete_payment()
224
- response=respond_chat(updated_text)
 
 
 
 
 
 
 
 
 
 
225
 
226
- else:
227
- response=respond_chat(text)
228
  col1,col2=st.columns([2,1])
229
  with col2:
230
  st.write("### Thought Process")
 
204
  document_button=st.pills("Ask based on Documents", ['search'], selection_mode="single")
205
  generate_button=st.button("Generate Response")
206
  if generate_button:
207
+ with st.spinner("Generating code..."):
208
+ try:
209
+ if document_button:
210
+ graph=load_graph(st.session_state.embeddings,st.session_state.chunks)
211
+ graph=graph.compile()
212
+ initial_state = {
213
+ "embedded_query":embed_sentence(text),
214
+ "knowledge": [],
215
+ "summary": "",
216
+ "final_response": None,}
217
+ final_state = graph.invoke(initial_state)
218
+ updated_text = f"""
219
+ Then respond to the client. Also follow the retrived information in the ##Summary section.
220
+ ## Instructions:
221
+ {text}
222
+ ## Summary:
223
+ {final_state['summary']}
224
+ """
225
+ complete_payment()
226
+ if st.session_state.db_transaction:
227
+ response=respond_chat(updated_text)
228
+
229
+ else:
230
+ complete_payment()
231
+ if st.session_state.db_transaction:
232
+ response=respond_chat(text)
233
+ except Exception as e:
234
+ st.error(f"Error during code generation: {e}")
235
 
 
 
236
  col1,col2=st.columns([2,1])
237
  with col2:
238
  st.write("### Thought Process")