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

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +26 -25
src/streamlit_app.py CHANGED
@@ -204,31 +204,32 @@ 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
- 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}")
 
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
+ complete_payment()
208
+ if st.session_state.db_transaction:
209
+
210
+ with st.spinner("Generating code..."):
211
+ try:
212
+ if document_button:
213
+ graph=load_graph(st.session_state.embeddings,st.session_state.chunks)
214
+ graph=graph.compile()
215
+ initial_state = {
216
+ "embedded_query":embed_sentence(text),
217
+ "knowledge": [],
218
+ "summary": "",
219
+ "final_response": None,}
220
+ final_state = graph.invoke(initial_state)
221
+ updated_text = f"""
222
+ Then respond to the client. Also follow the retrived information in the ##Summary section.
223
+ ## Instructions:
224
+ {text}
225
+ ## Summary:
226
+ {final_state['summary']}
227
+ """
228
+ complete_payment()
229
+
230
+ response=respond_chat(updated_text)
231
+
232
+ else:
233
  response=respond_chat(text)
234
  except Exception as e:
235
  st.error(f"Error during code generation: {e}")