Update app.py
Browse files
app.py
CHANGED
@@ -436,14 +436,13 @@ with gr.Blocks(css=custom_css) as iface:
|
|
436 |
# yield response
|
437 |
|
438 |
def stream_response(question):
|
439 |
-
|
440 |
for chunk_response, _ in process_question(question):
|
441 |
-
|
442 |
-
|
443 |
-
current_text = chunk_response
|
444 |
-
if new_text.strip(): # S'il y a du nouveau texte à afficher
|
445 |
-
time.sleep(0.05) # Petit délai pour rendre le streaming visible
|
446 |
yield chunk_response
|
|
|
|
|
447 |
|
448 |
submit_btn.click(
|
449 |
fn=stream_response,
|
|
|
436 |
# yield response
|
437 |
|
438 |
def stream_response(question):
|
439 |
+
previous_words = []
|
440 |
for chunk_response, _ in process_question(question):
|
441 |
+
current_words = chunk_response.split()
|
442 |
+
if len(current_words) > len(previous_words):
|
|
|
|
|
|
|
443 |
yield chunk_response
|
444 |
+
previous_words = current_words
|
445 |
+
time.sleep(0.05)
|
446 |
|
447 |
submit_btn.click(
|
448 |
fn=stream_response,
|