Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,25 +23,23 @@ 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, color=None):
|
27 |
button_id = f"cloud-button-{key or label}"
|
28 |
color_class = f"color-{color}" if color else ""
|
29 |
-
num_circles =
|
30 |
-
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
-
# Create circles on the left side
|
35 |
-
left_circles = ''.join([f'<div class="circle" style="margin-left: {-spacing * i}px;"></div>' for i in range(num_circles)])
|
36 |
-
|
37 |
-
# Create circles on the right side
|
38 |
-
right_circles = ''.join([f'<div class="circle" style="margin-right: {-spacing * i}px;"></div>' for i in range(num_circles)])
|
39 |
|
40 |
cloud_button_html = f"""
|
41 |
<div class="cloud {color_class}" id="{button_id}" style="margin-bottom: 20px;">
|
42 |
-
{
|
43 |
<div class="rectangle">{label}</div>
|
44 |
-
{right_circles}
|
45 |
</div>
|
46 |
<style>
|
47 |
.cloud {{
|
@@ -72,8 +70,10 @@ def cloud_button(label, key=None, color=None):
|
|
72 |
border-radius: 50%;
|
73 |
width: 30px;
|
74 |
height: 30px;
|
75 |
-
position:
|
76 |
z-index: 1;
|
|
|
|
|
77 |
}}
|
78 |
.cloud:hover .rectangle {{
|
79 |
background-color: #008CBA;
|
@@ -88,7 +88,7 @@ def cloud_button(label, key=None, color=None):
|
|
88 |
</style>
|
89 |
<script>
|
90 |
document.getElementById("{button_id}").onclick = function() {{
|
91 |
-
//
|
92 |
}};
|
93 |
</script>
|
94 |
"""
|
@@ -96,7 +96,6 @@ def cloud_button(label, key=None, color=None):
|
|
96 |
|
97 |
|
98 |
|
99 |
-
|
100 |
def load_pdf(file_path):
|
101 |
pdf_reader = PdfReader(file_path)
|
102 |
text = ""
|
@@ -165,20 +164,10 @@ def main():
|
|
165 |
# Main content
|
166 |
st.title("Welcome to BinDocs ChatBot! 🤖")
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
cloud_button("
|
171 |
-
|
172 |
-
cloud_button("Wofür wird die Alpha-ID verwendet?", color="2")
|
173 |
-
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True) # Space after the cloud button
|
174 |
-
cloud_button("Was sind die Vorteile des ambulanten operierens?", color="3")
|
175 |
-
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True) # Space after the cloud button
|
176 |
-
cloud_button("Was kann ich mit dem Prognose-Analyse Toll machen?", color="4")
|
177 |
-
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True) # Space after the cloud button
|
178 |
-
cloud_button("Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?", color="5")
|
179 |
-
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True) # Space after the cloud button
|
180 |
-
cloud_button("Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?", color="6")
|
181 |
-
st.markdown("<div style='margin-bottom: 20px;'></div>", unsafe_allow_html=True) # Space after the cloud button
|
182 |
|
183 |
pdf_path = "path_to_your_pdf_file.pdf" # Update this to the path of your PDF file
|
184 |
if not os.path.exists(pdf_path):
|
|
|
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 estimate_num_circles(text, character_width=7, circle_diameter=30):
|
27 |
+
text_width = len(text) * character_width
|
28 |
+
num_circles = text_width // (circle_diameter * 0.75) # 75% overlap
|
29 |
+
return max(int(num_circles), 3) # Ensure at least 3 circles
|
30 |
+
|
31 |
def cloud_button(label, key=None, color=None):
|
32 |
button_id = f"cloud-button-{key or label}"
|
33 |
color_class = f"color-{color}" if color else ""
|
34 |
+
num_circles = estimate_num_circles(label)
|
35 |
+
|
36 |
+
# Generate circles
|
37 |
+
circles_html = ''.join([f'<div class="circle" style="left: {-i * 30}px;"></div>' for i in range(num_circles)])
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
cloud_button_html = f"""
|
40 |
<div class="cloud {color_class}" id="{button_id}" style="margin-bottom: 20px;">
|
41 |
+
{circles_html}
|
42 |
<div class="rectangle">{label}</div>
|
|
|
43 |
</div>
|
44 |
<style>
|
45 |
.cloud {{
|
|
|
70 |
border-radius: 50%;
|
71 |
width: 30px;
|
72 |
height: 30px;
|
73 |
+
position: absolute;
|
74 |
z-index: 1;
|
75 |
+
top: 50%;
|
76 |
+
transform: translateY(-50%);
|
77 |
}}
|
78 |
.cloud:hover .rectangle {{
|
79 |
background-color: #008CBA;
|
|
|
88 |
</style>
|
89 |
<script>
|
90 |
document.getElementById("{button_id}").onclick = function() {{
|
91 |
+
// Add your JavaScript code here
|
92 |
}};
|
93 |
</script>
|
94 |
"""
|
|
|
96 |
|
97 |
|
98 |
|
|
|
99 |
def load_pdf(file_path):
|
100 |
pdf_reader = PdfReader(file_path)
|
101 |
text = ""
|
|
|
164 |
# Main content
|
165 |
st.title("Welcome to BinDocs ChatBot! 🤖")
|
166 |
|
167 |
+
cloud_button("Short Text", color="1")
|
168 |
+
cloud_button("This is a longer piece of text", color="2")
|
169 |
+
cloud_button("This is an even longer piece of text to test the cloud button", color="3")
|
170 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
pdf_path = "path_to_your_pdf_file.pdf" # Update this to the path of your PDF file
|
173 |
if not os.path.exists(pdf_path):
|