Anne31415 commited on
Commit
c1aafe3
·
1 Parent(s): efc06cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -47,14 +47,21 @@ cloud_button_style = """
47
  st.markdown(cloud_button_style, unsafe_allow_html=True)
48
 
49
  def cloud_button(label, key):
50
- button_html = f'<button type="button" class="cloud-button">{label}</button>'
51
- button_click = st.markdown(button_html, unsafe_allow_html=True)
52
- if button_click:
 
 
 
 
 
53
  st.session_state[key] = not st.session_state.get(key, False)
 
54
  return st.session_state.get(key, False)
55
 
56
 
57
 
 
58
 
59
  # Step 1: Clone the Dataset Repository
60
  repo = Repository(
@@ -159,19 +166,16 @@ def main():
159
  if pdf_path is not None:
160
  query = st.text_input("Ask questions about your PDF file (in any preferred language):")
161
 
162
-
163
- if st.markdown('<button class="cloud-button">Was genau ist ein Belegarzt?</button>', unsafe_allow_html=True):
164
  query = "Was genau ist ein Belegarzt?"
165
-
166
- if cloud_button("Wofür wird die Alpha-ID verwendet?", "alpha_id"):
167
  query = "Wofür wird die Alpha-ID verwendet?"
168
-
 
169
  if st.button("Was sind die Vorteile des ambulanten operierens?"):
170
  query = "Was sind die Vorteile des ambulanten operierens?"
171
-
172
-
173
- if st.button("Ask") or (not st.session_state['chat_history'] and query) or (st.session_state['chat_history'] and query != st.session_state['chat_history'][-1][1]):
174
- st.session_state['chat_history'].append(("User", query, "new"))
175
 
176
  loading_message = st.empty()
177
  loading_message.text('Bot is thinking...')
 
47
  st.markdown(cloud_button_style, unsafe_allow_html=True)
48
 
49
  def cloud_button(label, key):
50
+ # Create a placeholder for the button
51
+ button_placeholder = st.empty()
52
+
53
+ # Check if the button was previously clicked
54
+ was_clicked = button_placeholder.button(label, key=key)
55
+
56
+ # If clicked, update the session state
57
+ if was_clicked:
58
  st.session_state[key] = not st.session_state.get(key, False)
59
+
60
  return st.session_state.get(key, False)
61
 
62
 
63
 
64
+
65
 
66
  # Step 1: Clone the Dataset Repository
67
  repo = Repository(
 
166
  if pdf_path is not None:
167
  query = st.text_input("Ask questions about your PDF file (in any preferred language):")
168
 
169
+ # Use the cloud_button function for the custom styled buttons
170
+ if cloud_button("Was genau ist ein Belegarzt?", "belegarzt_button"):
171
  query = "Was genau ist ein Belegarzt?"
172
+
173
+ if cloud_button("Wofür wird die Alpha-ID verwendet?", "alpha_id_button"):
174
  query = "Wofür wird die Alpha-ID verwendet?"
175
+
176
+ # For default styled buttons, use st.button
177
  if st.button("Was sind die Vorteile des ambulanten operierens?"):
178
  query = "Was sind die Vorteile des ambulanten operierens?"
 
 
 
 
179
 
180
  loading_message = st.empty()
181
  loading_message.text('Bot is thinking...')