Spaces:
Runtime error
Runtime error
update css and js to have a blinking status
Browse files- app.py +11 -3
- assets/style.css +18 -30
- assets/utils_javascript.py +38 -59
app.py
CHANGED
|
@@ -22,6 +22,7 @@ from assets.utils_javascript import (
|
|
| 22 |
accordion_trigger_end,
|
| 23 |
accordion_trigger_spinoza,
|
| 24 |
accordion_trigger_spinoza_end,
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
init_env()
|
|
@@ -295,6 +296,10 @@ with open("./assets/source_information.md", "r") as f:
|
|
| 295 |
def start_agents():
|
| 296 |
gr.Info(message="The agents and Spinoza are loading...", duration=3)
|
| 297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
|
| 299 |
def end_agents():
|
| 300 |
gr.Info(
|
|
@@ -304,7 +309,7 @@ def end_agents():
|
|
| 304 |
|
| 305 |
|
| 306 |
def next_call():
|
| 307 |
-
|
| 308 |
|
| 309 |
|
| 310 |
init_prompt = """
|
|
@@ -319,6 +324,7 @@ What do you want to learn ?
|
|
| 319 |
with gr.Blocks(
|
| 320 |
title=f"馃攳 Spinoza",
|
| 321 |
css=css,
|
|
|
|
| 322 |
theme=theme,
|
| 323 |
) as demo:
|
| 324 |
chatbots = {}
|
|
@@ -472,7 +478,9 @@ with gr.Blocks(
|
|
| 472 |
with gr.Column(scale=1):
|
| 473 |
gr.Markdown("For any issue contact **spinoza.support@ekimetrics.com**.")
|
| 474 |
|
| 475 |
-
ask.submit(
|
|
|
|
|
|
|
| 476 |
fn=reformulate_questions,
|
| 477 |
inputs=[ask],
|
| 478 |
outputs=[agent_questions[tab] for tab in config["tabs"]],
|
|
@@ -502,4 +510,4 @@ with gr.Blocks(
|
|
| 502 |
|
| 503 |
|
| 504 |
if __name__ == "__main__":
|
| 505 |
-
demo.queue().launch(
|
|
|
|
| 22 |
accordion_trigger_end,
|
| 23 |
accordion_trigger_spinoza,
|
| 24 |
accordion_trigger_spinoza_end,
|
| 25 |
+
update_footer,
|
| 26 |
)
|
| 27 |
|
| 28 |
init_env()
|
|
|
|
| 296 |
def start_agents():
|
| 297 |
gr.Info(message="The agents and Spinoza are loading...", duration=3)
|
| 298 |
|
| 299 |
+
return [
|
| 300 |
+
(None, "I am waiting until all the agents are done to generate an answer...")
|
| 301 |
+
]
|
| 302 |
+
|
| 303 |
|
| 304 |
def end_agents():
|
| 305 |
gr.Info(
|
|
|
|
| 309 |
|
| 310 |
|
| 311 |
def next_call():
|
| 312 |
+
return
|
| 313 |
|
| 314 |
|
| 315 |
init_prompt = """
|
|
|
|
| 324 |
with gr.Blocks(
|
| 325 |
title=f"馃攳 Spinoza",
|
| 326 |
css=css,
|
| 327 |
+
js=update_footer(),
|
| 328 |
theme=theme,
|
| 329 |
) as demo:
|
| 330 |
chatbots = {}
|
|
|
|
| 478 |
with gr.Column(scale=1):
|
| 479 |
gr.Markdown("For any issue contact **spinoza.support@ekimetrics.com**.")
|
| 480 |
|
| 481 |
+
ask.submit(
|
| 482 |
+
start_agents, inputs=[], outputs=[chatbots["spinoza"]], js=accordion_trigger()
|
| 483 |
+
).then(
|
| 484 |
fn=reformulate_questions,
|
| 485 |
inputs=[ask],
|
| 486 |
outputs=[agent_questions[tab] for tab in config["tabs"]],
|
|
|
|
| 510 |
|
| 511 |
|
| 512 |
if __name__ == "__main__":
|
| 513 |
+
demo.queue().launch(debug=True)
|
assets/style.css
CHANGED
|
@@ -265,9 +265,15 @@ label.selected {
|
|
| 265 |
|
| 266 |
}
|
| 267 |
|
| 268 |
-
footer {
|
| 269 |
visibility: hidden;
|
| 270 |
display: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
/* @media screen and (max-width: 767px) {
|
|
@@ -406,32 +412,14 @@ span.chatbot>p>img {
|
|
| 406 |
background-color: white;
|
| 407 |
}
|
| 408 |
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
box-shadow: 0 0 0 3px inset #fff;
|
| 421 |
-
animation: l2-1 1s infinite;
|
| 422 |
-
}
|
| 423 |
-
.loader:after {
|
| 424 |
-
--s: -1;
|
| 425 |
-
}
|
| 426 |
-
@keyframes l2-0 {
|
| 427 |
-
0%,
|
| 428 |
-
50% {transform:rotate(0deg)}
|
| 429 |
-
80%,
|
| 430 |
-
100% {transform:rotate(180deg)}
|
| 431 |
-
}
|
| 432 |
-
@keyframes l2-1 {
|
| 433 |
-
0% {transform:translate(0)}
|
| 434 |
-
50%,
|
| 435 |
-
80% {transform:translate(calc(var(--s,1)*2.5px))}
|
| 436 |
-
100% {transform:translate(0)}
|
| 437 |
-
} */
|
|
|
|
| 265 |
|
| 266 |
}
|
| 267 |
|
| 268 |
+
/* footer {
|
| 269 |
visibility: hidden;
|
| 270 |
display: none !important;
|
| 271 |
+
} */
|
| 272 |
+
|
| 273 |
+
.footer-ekimetrics {
|
| 274 |
+
display: flex;
|
| 275 |
+
align-items: center;
|
| 276 |
+
margin-left: var(--size-2);
|
| 277 |
}
|
| 278 |
|
| 279 |
/* @media screen and (max-width: 767px) {
|
|
|
|
| 412 |
background-color: white;
|
| 413 |
}
|
| 414 |
|
| 415 |
+
.loader {
|
| 416 |
+
animation: blink 2s linear infinite;
|
| 417 |
+
}
|
| 418 |
+
@keyframes blink {
|
| 419 |
+
0% {
|
| 420 |
+
opacity: 0;
|
| 421 |
+
}
|
| 422 |
+
100% {
|
| 423 |
+
opacity: 1;
|
| 424 |
+
}
|
| 425 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/utils_javascript.py
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def accordion_trigger():
|
| 2 |
return """
|
| 3 |
function accordion_trigger() {
|
|
@@ -9,16 +23,25 @@ def accordion_trigger():
|
|
| 9 |
var accordion_politique = document.getElementById("accordion-politique")
|
| 10 |
var accordion_legal = document.getElementById("accordion-legal")
|
| 11 |
var accordion_ademe= document.getElementById("accordion-ademe")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
accordion_politique.children[1].children[0].
|
| 18 |
-
accordion_legal.children[1].children[0].textContent = "Law agent
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
});
|
| 24 |
}
|
|
@@ -34,16 +57,10 @@ def accordion_trigger_end():
|
|
| 34 |
var accordion_legal = document.getElementById("accordion-legal")
|
| 35 |
var accordion_ademe = document.getElementById("accordion-ademe")
|
| 36 |
accordion_science.children[1].children[0].textContent = "Science agent - ready";
|
| 37 |
-
accordion_science.children[1].children[1].classList.remove('loader');
|
| 38 |
accordion_presse.children[1].children[0].textContent = "Press agent - ready";
|
| 39 |
-
accordion_presse.children[1].children[0].classList.remove('loader');
|
| 40 |
accordion_politique.children[1].children[0].textContent = "Politics agent - ready";
|
| 41 |
-
accordion_politique.children[1].children[0].classList.remove('loader');
|
| 42 |
accordion_legal.children[1].children[0].textContent = "Law agent - ready";
|
| 43 |
-
accordion_legal.children[1].children[0].classList.remove('loader');
|
| 44 |
accordion_ademe.children[1].children[0].textContent = "ADEME agent - ready";
|
| 45 |
-
accordion_ademe.children[1].children[0].classList.remove('loader');
|
| 46 |
-
|
| 47 |
}
|
| 48 |
"""
|
| 49 |
|
|
@@ -52,8 +69,11 @@ def accordion_trigger_spinoza():
|
|
| 52 |
return """
|
| 53 |
function accordion_trigger_spinoza() {
|
| 54 |
var accordion_spinoza = document.getElementById("accordion-spinoza")
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
"""
|
| 59 |
|
|
@@ -63,46 +83,5 @@ def accordion_trigger_spinoza_end():
|
|
| 63 |
function accordion_trigger_spinoza_end() {
|
| 64 |
var accordion_spinoza = document.getElementById("accordion-spinoza")
|
| 65 |
accordion_spinoza.children[1].children[0].textContent = "Spinoza - ready";
|
| 66 |
-
accordion_spinoza.children[1].children[0].classList.remove('loader');
|
| 67 |
-
}
|
| 68 |
-
"""
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
def accordion_trigger_end_science():
|
| 72 |
-
return """
|
| 73 |
-
function accordion_trigger_end() {
|
| 74 |
-
var accordion_science = document.getElementById("accordion-science")
|
| 75 |
-
accordion_science.children[1].children[0].textContent = "Science agent - ready";
|
| 76 |
-
console.log("DONE - end science")
|
| 77 |
-
}
|
| 78 |
-
"""
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
def accordion_trigger_end_presse():
|
| 82 |
-
return """
|
| 83 |
-
function accordion_trigger_end() {
|
| 84 |
-
var accordion_presse = document.getElementById("accordion-presse")
|
| 85 |
-
accordion_presse.children[1].children[0].textContent = "Presse agent - ready";
|
| 86 |
-
console.log("DONE - end presse")
|
| 87 |
-
}
|
| 88 |
-
"""
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
def accordion_trigger_end_politique():
|
| 92 |
-
return """
|
| 93 |
-
function accordion_trigger_end() {
|
| 94 |
-
var accordion_politique = document.getElementById("accordion-politique")
|
| 95 |
-
accordion_politique.children[1].children[0].textContent = "Politique agent - ready";
|
| 96 |
-
console.log("DONE - end politique")
|
| 97 |
-
}
|
| 98 |
-
"""
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
def accordion_trigger_end_legal():
|
| 102 |
-
return """
|
| 103 |
-
function accordion_trigger_end() {
|
| 104 |
-
var accordion_legal = document.getElementById("accordion-legal")
|
| 105 |
-
accordion_legal.children[1].children[0].textContent = "Legal agent - ready";
|
| 106 |
-
console.log("DONE - end legal")
|
| 107 |
}
|
| 108 |
"""
|
|
|
|
| 1 |
+
def update_footer():
|
| 2 |
+
return """
|
| 3 |
+
function update_footer() {
|
| 4 |
+
var footer = document.querySelector('footer')
|
| 5 |
+
footer.innerHTML = "<a href='https://rsf.org/fr' class='footer-ekimetrics' target='_blank' rel='noreferrer'>脌 l'initiative de RSF</a>";
|
| 6 |
+
footer.innerHTML += "<a href='https://www.alliancepresse.fr/' class='footer-ekimetrics' target='_blank' rel='noreferrer'>et l'Alliance Presse</a>";
|
| 7 |
+
footer.innerHTML += "<div class='footer-ekimetrics'> 路 </div>";
|
| 8 |
+
footer.innerHTML += "<a href='https://www.culture.gouv.fr/' class='footer-ekimetrics' target='_blank' rel='noreferrer'>Avec le soutien du Minist猫re de la Culture</a>";
|
| 9 |
+
footer.innerHTML += "<div class='footer-ekimetrics'> 路 </div>";
|
| 10 |
+
footer.innerHTML += "<a href='https://ekimetrics.com/' class='footer-ekimetrics' target='_blank' rel='noreferrer'>Con莽u par Ekimetrics</a>";
|
| 11 |
+
}
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
|
| 15 |
def accordion_trigger():
|
| 16 |
return """
|
| 17 |
function accordion_trigger() {
|
|
|
|
| 23 |
var accordion_politique = document.getElementById("accordion-politique")
|
| 24 |
var accordion_legal = document.getElementById("accordion-legal")
|
| 25 |
var accordion_ademe= document.getElementById("accordion-ademe")
|
| 26 |
+
var accordion_spinoza = document.getElementById("accordion-spinoza")
|
| 27 |
+
document.querySelectorAll(".loader").forEach(el => el.remove());
|
| 28 |
+
document.querySelectorAll(".loader-helper").forEach(el => el.remove());
|
| 29 |
+
accordion_science.children[1].children[0].textContent = "Science agent";
|
| 30 |
+
accordion_presse.children[1].children[0].textContent = "Press agent";
|
| 31 |
+
accordion_politique.children[1].children[0].textContent = "Politics agent";
|
| 32 |
+
accordion_legal.children[1].children[0].textContent = "Law agent";
|
| 33 |
+
accordion_ademe.children[1].children[0].textContent = "ADEME agent";
|
| 34 |
+
accordion_spinoza.children[1].children[0].textContent = "Spinoza";
|
| 35 |
+
accordion_science.children[1].children[0].innerHTML += "<span class='loader-helper'> - </span>";
|
| 36 |
+
accordion_science.children[1].children[0].innerHTML += "<span class='loader'>loading</span>";
|
| 37 |
+
accordion_presse.children[1].children[0].innerHTML += "<span class='loader-helper'> - </span>";
|
| 38 |
+
accordion_presse.children[1].children[0].innerHTML += "<span class='loader'>loading</span>";
|
| 39 |
+
accordion_politique.children[1].children[0].innerHTML += "<span class='loader-helper'> - </span>";
|
| 40 |
+
accordion_politique.children[1].children[0].innerHTML += "<span class='loader'>loading</span>";
|
| 41 |
+
accordion_legal.children[1].children[0].innerHTML += "<span class='loader-helper'> - </span>";
|
| 42 |
+
accordion_legal.children[1].children[0].innerHTML += "<span class='loader'>loading</span>";
|
| 43 |
+
accordion_ademe.children[1].children[0].innerHTML += "<span class='loader-helper'> - </span>";
|
| 44 |
+
accordion_ademe.children[1].children[0].innerHTML += "<span class='loader'>loading</span>";
|
| 45 |
}
|
| 46 |
});
|
| 47 |
}
|
|
|
|
| 57 |
var accordion_legal = document.getElementById("accordion-legal")
|
| 58 |
var accordion_ademe = document.getElementById("accordion-ademe")
|
| 59 |
accordion_science.children[1].children[0].textContent = "Science agent - ready";
|
|
|
|
| 60 |
accordion_presse.children[1].children[0].textContent = "Press agent - ready";
|
|
|
|
| 61 |
accordion_politique.children[1].children[0].textContent = "Politics agent - ready";
|
|
|
|
| 62 |
accordion_legal.children[1].children[0].textContent = "Law agent - ready";
|
|
|
|
| 63 |
accordion_ademe.children[1].children[0].textContent = "ADEME agent - ready";
|
|
|
|
|
|
|
| 64 |
}
|
| 65 |
"""
|
| 66 |
|
|
|
|
| 69 |
return """
|
| 70 |
function accordion_trigger_spinoza() {
|
| 71 |
var accordion_spinoza = document.getElementById("accordion-spinoza")
|
| 72 |
+
document.querySelectorAll(".loader").forEach(el => el.remove());
|
| 73 |
+
document.querySelectorAll(".loader-helper").forEach(el => el.remove());
|
| 74 |
+
accordion_spinoza.children[1].children[0].textContent = "Spinoza";
|
| 75 |
+
accordion_spinoza.children[1].children[0].innerHTML += "<span class='loader-helper'> - </span>";
|
| 76 |
+
accordion_spinoza.children[1].children[0].innerHTML += "<span class='loader'>generating</span>";
|
| 77 |
}
|
| 78 |
"""
|
| 79 |
|
|
|
|
| 83 |
function accordion_trigger_spinoza_end() {
|
| 84 |
var accordion_spinoza = document.getElementById("accordion-spinoza")
|
| 85 |
accordion_spinoza.children[1].children[0].textContent = "Spinoza - ready";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
}
|
| 87 |
"""
|