This commit is contained in:
parent
a917867405
commit
fdeae7846d
23
src/app.py
23
src/app.py
|
|
@ -8,8 +8,8 @@ from src.router import SmartRouter
|
|||
|
||||
@cl.on_chat_start
|
||||
async def on_chat_start():
|
||||
# Welcome message without emojis, more natural
|
||||
await cl.Message(content="**Antigravity Brain Online**\n\nEstou pronto para ajudar. Pode me dizer o que precisa? Por exemplo: *'Verificar a saúde do servidor'* ou *'Criar um novo agente'*.").send()
|
||||
# Welcome message - Gnarl from Overlord franchise
|
||||
await cl.Message(content="**Gnarl Online**\n\nMestre, estou pronto para servi-lo. O que deseja? Por exemplo: *'Verificar a saúde do servidor'* ou *'Criar um novo agente'*.", author="Gnarl").send()
|
||||
cl.user_session.set("selected_crew", None)
|
||||
|
||||
@cl.on_message
|
||||
|
|
@ -33,19 +33,12 @@ async def on_message(message: cl.Message):
|
|||
# No, that's risky. Let's stick to: Route First -> Sticky -> User can /reset.
|
||||
|
||||
if not current_crew:
|
||||
# Show loading indicator while routing
|
||||
msg_routing = cl.Message(content="Analisando sua solicitação...")
|
||||
await msg_routing.send()
|
||||
|
||||
# Route silently without showing routing details to user
|
||||
current_crew = SmartRouter.route(user_input)
|
||||
cl.user_session.set("selected_crew", current_crew)
|
||||
|
||||
await msg_routing.update()
|
||||
await cl.Message(content=f"**Direcionando para:** {current_crew}").send()
|
||||
|
||||
# 3. Execution with proper loading indicator
|
||||
# Create a message that will show loading state and be updated with the result
|
||||
msg = cl.Message(content=f"**{current_crew}** está processando sua solicitação...")
|
||||
# 3. Execution - show only thinking indicator
|
||||
msg = cl.Message(content="Pensando...", author="Gnarl")
|
||||
await msg.send()
|
||||
|
||||
try:
|
||||
|
|
@ -57,12 +50,12 @@ async def on_message(message: cl.Message):
|
|||
result = crew.kickoff(inputs={"topic": user_input})
|
||||
final_answer = str(result)
|
||||
|
||||
# Update message with final result
|
||||
msg.content = f"### Relatório de {current_crew}\n\n{final_answer}"
|
||||
# Update message with clean result (no crew info)
|
||||
msg.content = final_answer
|
||||
await msg.update()
|
||||
|
||||
except Exception as e:
|
||||
msg.content = f"**Erro ao processar solicitação:** {str(e)}"
|
||||
msg.content = f"Mestre, encontrei um problema: {str(e)}"
|
||||
await msg.update()
|
||||
# Reset crew on failure so user can try again or get re-routed
|
||||
cl.user_session.set("selected_crew", None)
|
||||
|
|
|
|||
Loading…
Reference in New Issue