Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -341,7 +341,11 @@ def criar_interface():
|
|
341 |
""")
|
342 |
|
343 |
with gr.Column(scale=1):
|
344 |
-
timer = gr.Number(
|
|
|
|
|
|
|
|
|
345 |
progress = gr.Slider(
|
346 |
value=0,
|
347 |
minimum=0,
|
@@ -356,7 +360,8 @@ def criar_interface():
|
|
356 |
chat = gr.Chatbot(
|
357 |
value=[[None, coach.primeira_pergunta()]],
|
358 |
height=500,
|
359 |
-
show_label=False
|
|
|
360 |
)
|
361 |
|
362 |
with gr.Row():
|
@@ -429,57 +434,11 @@ def criar_interface():
|
|
429 |
- [Exercício] Análise de Decisões Passadas
|
430 |
- [Template] Documentação de Decisões Importantes
|
431 |
""")
|
432 |
-
|
433 |
-
with gr.Row():
|
434 |
-
with gr.Accordion("🔄 Práticas Recomendadas", open=False):
|
435 |
-
gr.Markdown("""
|
436 |
-
### 📝 Dicas para Reflexão Efetiva
|
437 |
-
1. Reserve um momento tranquilo para suas reflexões
|
438 |
-
2. Seja específico em seus exemplos
|
439 |
-
3. Conecte suas experiências com aprendizados
|
440 |
-
4. Considere diferentes perspectivas
|
441 |
-
5. Anote insights importantes
|
442 |
-
|
443 |
-
### 🎯 Como Aproveitar o Feedback
|
444 |
-
1. Revise os pontos destacados
|
445 |
-
2. Faça conexões com situações atuais
|
446 |
-
3. Defina ações práticas
|
447 |
-
4. Estabeleça prazos para implementação
|
448 |
-
5. Acompanhe seu progresso
|
449 |
-
""")
|
450 |
|
451 |
def atualizar_timer():
|
452 |
"""Update session timer"""
|
453 |
-
|
454 |
-
|
455 |
-
def atualizar_progresso():
|
456 |
-
"""Update progress bar"""
|
457 |
-
return gr.update(value=coach.pergunta_atual)
|
458 |
-
|
459 |
-
def atualizar_tema():
|
460 |
-
"""Update current theme"""
|
461 |
-
if coach.pergunta_atual < len(PERGUNTAS):
|
462 |
-
return PERGUNTAS[coach.pergunta_atual]["categoria"].title()
|
463 |
-
return "Jornada Concluída"
|
464 |
-
|
465 |
-
def atualizar_tempo_resposta():
|
466 |
-
"""Update response timer"""
|
467 |
-
return coach.get_tempo_ultima_resposta()
|
468 |
-
|
469 |
-
def limpar_chat():
|
470 |
-
"""Reset chat and all related components"""
|
471 |
-
coach.__init__() # Reset coach state
|
472 |
-
return {
|
473 |
-
chat: [[None, coach.primeira_pergunta()]],
|
474 |
-
txt: "",
|
475 |
-
progress: 0,
|
476 |
-
tema_atual: "Autoconhecimento",
|
477 |
-
tempo_resposta: "0:00",
|
478 |
-
sentiment_chart: None,
|
479 |
-
word_cloud: None,
|
480 |
-
temas_fortes: "",
|
481 |
-
areas_desenvolvimento: ""
|
482 |
-
}
|
483 |
|
484 |
def responder(mensagem, historico):
|
485 |
"""Process user response and update interface"""
|
@@ -489,9 +448,15 @@ def criar_interface():
|
|
489 |
chat: historico
|
490 |
}
|
491 |
|
|
|
|
|
|
|
492 |
# Generate response
|
493 |
resposta = coach.gerar_resposta(mensagem)
|
494 |
-
|
|
|
|
|
|
|
495 |
|
496 |
# Update visualizations
|
497 |
sentiment_analysis = None
|
@@ -504,12 +469,15 @@ def criar_interface():
|
|
504 |
word_cloud_plot = generate_word_cloud(coach.historico_respostas)
|
505 |
strong_themes, development_areas = analyze_themes(coach.historico_respostas)
|
506 |
|
|
|
|
|
|
|
507 |
return {
|
508 |
txt: "",
|
509 |
chat: historico,
|
510 |
-
timer:
|
511 |
progress: coach.pergunta_atual,
|
512 |
-
tema_atual:
|
513 |
tempo_resposta: "0:00",
|
514 |
sentiment_chart: sentiment_analysis,
|
515 |
word_cloud: word_cloud_plot,
|
@@ -517,6 +485,22 @@ def criar_interface():
|
|
517 |
areas_desenvolvimento: development_areas
|
518 |
}
|
519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
# Event handlers
|
521 |
txt.submit(
|
522 |
responder,
|
@@ -540,8 +524,11 @@ def criar_interface():
|
|
540 |
)
|
541 |
|
542 |
# Periodic updates
|
543 |
-
|
544 |
-
|
|
|
|
|
|
|
545 |
|
546 |
return app
|
547 |
|
|
|
341 |
""")
|
342 |
|
343 |
with gr.Column(scale=1):
|
344 |
+
timer = gr.Number(
|
345 |
+
value=0,
|
346 |
+
label="⏱️ Tempo de Reflexão (minutos)",
|
347 |
+
interactive=False
|
348 |
+
)
|
349 |
progress = gr.Slider(
|
350 |
value=0,
|
351 |
minimum=0,
|
|
|
360 |
chat = gr.Chatbot(
|
361 |
value=[[None, coach.primeira_pergunta()]],
|
362 |
height=500,
|
363 |
+
show_label=False,
|
364 |
+
type="messages" # Fixing the deprecation warning
|
365 |
)
|
366 |
|
367 |
with gr.Row():
|
|
|
434 |
- [Exercício] Análise de Decisões Passadas
|
435 |
- [Template] Documentação de Decisões Importantes
|
436 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
|
438 |
def atualizar_timer():
|
439 |
"""Update session timer"""
|
440 |
+
tempo = int((datetime.now() - coach.inicio).total_seconds() / 60)
|
441 |
+
return tempo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
|
443 |
def responder(mensagem, historico):
|
444 |
"""Process user response and update interface"""
|
|
|
448 |
chat: historico
|
449 |
}
|
450 |
|
451 |
+
# Convert message to the new format
|
452 |
+
nova_mensagem = {"role": "user", "content": mensagem}
|
453 |
+
|
454 |
# Generate response
|
455 |
resposta = coach.gerar_resposta(mensagem)
|
456 |
+
resposta_formatada = {"role": "assistant", "content": resposta}
|
457 |
+
|
458 |
+
# Update history in the new format
|
459 |
+
historico.append((nova_mensagem, resposta_formatada))
|
460 |
|
461 |
# Update visualizations
|
462 |
sentiment_analysis = None
|
|
|
469 |
word_cloud_plot = generate_word_cloud(coach.historico_respostas)
|
470 |
strong_themes, development_areas = analyze_themes(coach.historico_respostas)
|
471 |
|
472 |
+
# Update timer
|
473 |
+
tempo_atual = atualizar_timer()
|
474 |
+
|
475 |
return {
|
476 |
txt: "",
|
477 |
chat: historico,
|
478 |
+
timer: tempo_atual,
|
479 |
progress: coach.pergunta_atual,
|
480 |
+
tema_atual: PERGUNTAS[min(coach.pergunta_atual, len(PERGUNTAS)-1)]["categoria"].title(),
|
481 |
tempo_resposta: "0:00",
|
482 |
sentiment_chart: sentiment_analysis,
|
483 |
word_cloud: word_cloud_plot,
|
|
|
485 |
areas_desenvolvimento: development_areas
|
486 |
}
|
487 |
|
488 |
+
def limpar_chat():
|
489 |
+
"""Reset chat and all related components"""
|
490 |
+
coach.__init__() # Reset coach state
|
491 |
+
primeira_msg = {"role": "assistant", "content": coach.primeira_pergunta()}
|
492 |
+
return {
|
493 |
+
chat: [[None, primeira_msg]],
|
494 |
+
txt: "",
|
495 |
+
progress: 0,
|
496 |
+
tema_atual: "Autoconhecimento",
|
497 |
+
tempo_resposta: "0:00",
|
498 |
+
sentiment_chart: None,
|
499 |
+
word_cloud: None,
|
500 |
+
temas_fortes: "",
|
501 |
+
areas_desenvolvimento: ""
|
502 |
+
}
|
503 |
+
|
504 |
# Event handlers
|
505 |
txt.submit(
|
506 |
responder,
|
|
|
524 |
)
|
525 |
|
526 |
# Periodic updates
|
527 |
+
gr.on(
|
528 |
+
triggers=[gr.EventListener(every=1)],
|
529 |
+
fn=atualizar_timer,
|
530 |
+
outputs=[timer]
|
531 |
+
)
|
532 |
|
533 |
return app
|
534 |
|