eswardivi commited on
Commit
2f1122d
1 Parent(s): 01a294a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -151,17 +151,19 @@ if "logs" not in st.session_state:
151
 
152
  with col1:
153
  if st.button("Submit"):
154
- if "graph.png" in os.listdir():
155
- os.remove("graph.png")
156
- st.session_state.logs = ""
157
- with st.spinner("Generating response..."):
158
- bot.query(query)
159
- answer_match= re.search(r"Answer:", st.session_state.logs)
160
- if answer_match:
161
- answer_end_index = answer_match.end()
162
- subsequent_text = st.session_state.logs[answer_end_index:].strip()
163
- st.success(subsequent_text)
164
-
 
 
165
  with col2:
166
  st.header("Output")
167
  if "graph.png" in os.listdir():
@@ -171,4 +173,4 @@ with col2:
171
  st.write("No plot generated yet.")
172
 
173
  st.header("Live Logs")
174
- st.text_area("Logs", value=st.session_state.logs, height=400)
 
151
 
152
  with col1:
153
  if st.button("Submit"):
154
+ if not query:
155
+ st.error("Please enter a query.")
156
+ else:
157
+ if "graph.png" in os.listdir():
158
+ os.remove("graph.png")
159
+ st.session_state.logs = ""
160
+ with st.spinner("Generating response..."):
161
+ bot.query(query)
162
+ answer_match = re.search(r"Answer:", st.session_state.logs)
163
+ if answer_match:
164
+ answer_end_index = answer_match.end()
165
+ subsequent_text = st.session_state.logs[answer_end_index:].strip()
166
+ st.success(subsequent_text)
167
  with col2:
168
  st.header("Output")
169
  if "graph.png" in os.listdir():
 
173
  st.write("No plot generated yet.")
174
 
175
  st.header("Live Logs")
176
+ st.text_area("Logs", value=st.session_state.logs, height=400, disabled=True)