Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -217,21 +217,29 @@ body {
|
|
217 |
"""
|
218 |
|
219 |
# Interface Gradio
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
|
|
229 |
"""
|
230 |
-
btn_text = "Mostrar Barra"
|
231 |
-
else:
|
232 |
-
cover_html = ""
|
233 |
btn_text = "Ocultar Barra"
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
def demo():
|
237 |
custom_css = """
|
@@ -241,15 +249,11 @@ def demo():
|
|
241 |
footer {
|
242 |
display: none !important;
|
243 |
}
|
244 |
-
.gradio-container {
|
245 |
-
margin-top: 0 !important;
|
246 |
-
}
|
247 |
-
/* Estilo do botão */
|
248 |
.cover-button {
|
249 |
position: fixed !important;
|
250 |
top: 10px !important;
|
251 |
right: 10px !important;
|
252 |
-
z-index:
|
253 |
font-size: 14px !important;
|
254 |
padding: 8px 16px !important;
|
255 |
background-color: #2563eb !important;
|
@@ -265,13 +269,20 @@ def demo():
|
|
265 |
"""
|
266 |
|
267 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="gray"), css=custom_css) as demo:
|
268 |
-
# Componentes para controle da barra
|
269 |
with gr.Row():
|
270 |
-
|
271 |
toggle_btn = gr.Button("Ocultar Barra", elem_classes="cover-button")
|
272 |
-
|
273 |
-
|
274 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
vector_db = gr.State()
|
276 |
qa_chain = gr.State()
|
277 |
collection_name = gr.State()
|
|
|
217 |
"""
|
218 |
|
219 |
# Interface Gradio
|
220 |
+
# Interface Gradio
|
221 |
+
def toggle_visibility(is_hidden):
|
222 |
+
if is_hidden:
|
223 |
+
# CSS para mostrar a barra
|
224 |
+
css = """
|
225 |
+
<style>
|
226 |
+
header.from-gray-50-to-white.relative.z-40.border-b.border-gray-100.bg-gradient-to-t.via-white.pt-0\\.5.dark\\:via-gray-950 {
|
227 |
+
display: flex !important;
|
228 |
+
}
|
229 |
+
</style>
|
230 |
"""
|
|
|
|
|
|
|
231 |
btn_text = "Ocultar Barra"
|
232 |
+
else:
|
233 |
+
# CSS para ocultar a barra
|
234 |
+
css = """
|
235 |
+
<style>
|
236 |
+
header.from-gray-50-to-white.relative.z-40.border-b.border-gray-100.bg-gradient-to-t.via-white.pt-0\\.5.dark\\:via-gray-950 {
|
237 |
+
display: none !important;
|
238 |
+
}
|
239 |
+
</style>
|
240 |
+
"""
|
241 |
+
btn_text = "Mostrar Barra"
|
242 |
+
return css, btn_text, not is_hidden
|
243 |
|
244 |
def demo():
|
245 |
custom_css = """
|
|
|
249 |
footer {
|
250 |
display: none !important;
|
251 |
}
|
|
|
|
|
|
|
|
|
252 |
.cover-button {
|
253 |
position: fixed !important;
|
254 |
top: 10px !important;
|
255 |
right: 10px !important;
|
256 |
+
z-index: 9999 !important;
|
257 |
font-size: 14px !important;
|
258 |
padding: 8px 16px !important;
|
259 |
background-color: #2563eb !important;
|
|
|
269 |
"""
|
270 |
|
271 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="gray"), css=custom_css) as demo:
|
|
|
272 |
with gr.Row():
|
273 |
+
css_html = gr.HTML("") # Para injetar o CSS dinamicamente
|
274 |
toggle_btn = gr.Button("Ocultar Barra", elem_classes="cover-button")
|
275 |
+
is_hidden = gr.State(False)
|
276 |
+
|
277 |
+
# Conectar o evento do botão
|
278 |
+
toggle_btn.click(
|
279 |
+
fn=toggle_visibility,
|
280 |
+
inputs=[is_hidden],
|
281 |
+
outputs=[css_html, toggle_btn, is_hidden],
|
282 |
+
show_progress=False
|
283 |
+
)
|
284 |
+
|
285 |
+
# Estado do sistema
|
286 |
vector_db = gr.State()
|
287 |
qa_chain = gr.State()
|
288 |
collection_name = gr.State()
|