Anne31415 commited on
Commit
13c5f18
·
1 Parent(s): a48e7a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -19
app.py CHANGED
@@ -23,10 +23,11 @@ repo.git_pull() # Pull the latest changes (if any)
23
  # Step 2: Load the PDF File
24
  pdf_file_path = "Private_Book/KOMBI_all2.pdf" # Replace with your PDF file path
25
 
26
- def cloud_button(label, key=None):
27
  button_id = f"cloud-button-{key or label}"
 
28
  cloud_button_html = f"""
29
- <div class="cloud" id="{button_id}">
30
  <div class="circle small"></div>
31
  <div class="circle medium"></div>
32
  <div class="circle large"></div>
@@ -40,6 +41,7 @@ def cloud_button(label, key=None):
40
  display: inline-block;
41
  cursor: pointer;
42
  user-select: none;
 
43
  }}
44
  .rectangle {{
45
  width: 120px;
@@ -83,17 +85,22 @@ def cloud_button(label, key=None):
83
  background-color: #008CBA;
84
  color: white;
85
  }}
 
 
 
 
 
 
86
  </style>
87
  <script>
88
  document.getElementById("{button_id}").onclick = function() {{
89
- google.script.run.withSuccessHandler(function(e) {{
90
- document.getElementById("{button_id}").innerText = e;
91
- }}).getCloudButtonValue("{label}");
92
  }};
93
  </script>
94
  """
95
  st.markdown(cloud_button_html, unsafe_allow_html=True)
96
 
 
97
  def load_pdf(file_path):
98
  pdf_reader = PdfReader(file_path)
99
  text = ""
@@ -139,8 +146,10 @@ def main():
139
  Hello! I’m here to assist you with:<br><br>
140
  📘 **Glossary Inquiries:**<br>
141
  I can clarify terms like "DiGA", "AOP", or "BfArM", providing clear and concise explanations to help you understand our content better.<br><br>
 
142
  🆘 **Help Page Navigation:**<br>
143
  Ask me if you forgot your password or want to know more about topics related to the platform.<br><br>
 
144
  📰 **Latest Whitepapers Insights:**<br>
145
  Curious about our recent publications? Feel free to ask about our latest whitepapers!<br><br>
146
  """, unsafe_allow_html=True)
@@ -148,6 +157,13 @@ def main():
148
  add_vertical_space(1) # Adjust as per the desired spacing
149
  st.write('Made with ❤️ by BinDoc GmbH')
150
  api_key = os.getenv("OPENAI_API_KEY")
 
 
 
 
 
 
 
151
 
152
  hide_streamlit_style = """
153
  <style>
@@ -177,20 +193,7 @@ def main():
177
 
178
  if pdf_path is not None:
179
  query = st.text_input("Ask questions about your PDF file (in any preferred language):")
180
-
181
- if cloud_button("Was genau ist ein Belegarzt?"):
182
- query = "Was genau ist ein Belegarzt?"
183
- if cloud_button("Wofür wird die Alpha-ID verwendet?"):
184
- query = "Wofür wird die Alpha-ID verwendet?"
185
- if cloud_button("Was sind die Vorteile des ambulanten operierens?"):
186
- query = "Was sind die Vorteile des ambulanten operierens?"
187
- if cloud_button("Was kann ich mit dem Prognose-Analyse Toll machen?"):
188
- query = "Was kann ich mit dem Prognose-Analyse Toll machen?"
189
- if cloud_button("Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?"):
190
- query = "Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?"
191
- if cloud_button("Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?"):
192
- query = "Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?"
193
-
194
  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]):
195
  st.session_state['chat_history'].append(("User", query, "new"))
196
  loading_message = st.empty()
@@ -209,5 +212,6 @@ def main():
209
  query = ""
210
  st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
211
 
 
212
  if __name__ == "__main__":
213
  main()
 
23
  # Step 2: Load the PDF File
24
  pdf_file_path = "Private_Book/KOMBI_all2.pdf" # Replace with your PDF file path
25
 
26
+ def cloud_button(label, key=None, color=None):
27
  button_id = f"cloud-button-{key or label}"
28
+ color_class = f"color-{color}" if color else ""
29
  cloud_button_html = f"""
30
+ <div class="cloud {color_class}" id="{button_id}">
31
  <div class="circle small"></div>
32
  <div class="circle medium"></div>
33
  <div class="circle large"></div>
 
41
  display: inline-block;
42
  cursor: pointer;
43
  user-select: none;
44
+ margin-right: 20px; /* Add space between cloud buttons */
45
  }}
46
  .rectangle {{
47
  width: 120px;
 
85
  background-color: #008CBA;
86
  color: white;
87
  }}
88
+ .color-1 .rectangle {{ background-color: #FFA07A; }}
89
+ .color-2 .rectangle {{ background-color: #FF7F50; }}
90
+ .color-3 .rectangle {{ background-color: #FF6347; }}
91
+ .color-4 .rectangle {{ background-color: #FF4500; }}
92
+ .color-5 .rectangle {{ background-color: #FF8C00; }}
93
+ .color-6 .rectangle {{ background-color: #FFD700; }}
94
  </style>
95
  <script>
96
  document.getElementById("{button_id}").onclick = function() {{
97
+ // Your existing JavaScript code for handling button click
 
 
98
  }};
99
  </script>
100
  """
101
  st.markdown(cloud_button_html, unsafe_allow_html=True)
102
 
103
+
104
  def load_pdf(file_path):
105
  pdf_reader = PdfReader(file_path)
106
  text = ""
 
146
  Hello! I’m here to assist you with:<br><br>
147
  📘 **Glossary Inquiries:**<br>
148
  I can clarify terms like "DiGA", "AOP", or "BfArM", providing clear and concise explanations to help you understand our content better.<br><br>
149
+
150
  🆘 **Help Page Navigation:**<br>
151
  Ask me if you forgot your password or want to know more about topics related to the platform.<br><br>
152
+
153
  📰 **Latest Whitepapers Insights:**<br>
154
  Curious about our recent publications? Feel free to ask about our latest whitepapers!<br><br>
155
  """, unsafe_allow_html=True)
 
157
  add_vertical_space(1) # Adjust as per the desired spacing
158
  st.write('Made with ❤️ by BinDoc GmbH')
159
  api_key = os.getenv("OPENAI_API_KEY")
160
+
161
+ cloud_button("Was genau ist ein Belegarzt?", color="1")
162
+ cloud_button("Wofür wird die Alpha-ID verwendet?", color="2")
163
+ cloud_button("Was sind die Vorteile des ambulanten operierens?", color="3")
164
+ cloud_button("Was kann ich mit dem Prognose-Analyse Toll machen?", color="4")
165
+ cloud_button("Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?", color="5")
166
+ cloud_button("Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?", color="6")
167
 
168
  hide_streamlit_style = """
169
  <style>
 
193
 
194
  if pdf_path is not None:
195
  query = st.text_input("Ask questions about your PDF file (in any preferred language):")
196
+
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  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]):
198
  st.session_state['chat_history'].append(("User", query, "new"))
199
  loading_message = st.empty()
 
212
  query = ""
213
  st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
214
 
215
+
216
  if __name__ == "__main__":
217
  main()