Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- 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 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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")
|