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
|
@cl.on_chat_start
|
||||||
async def on_chat_start():
|
async def on_chat_start():
|
||||||
# Welcome message without emojis, more natural
|
# Welcome message - Gnarl from Overlord franchise
|
||||||
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()
|
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.user_session.set("selected_crew", None)
|
||||||
|
|
||||||
@cl.on_message
|
@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.
|
# No, that's risky. Let's stick to: Route First -> Sticky -> User can /reset.
|
||||||
|
|
||||||
if not current_crew:
|
if not current_crew:
|
||||||
# Show loading indicator while routing
|
# Route silently without showing routing details to user
|
||||||
msg_routing = cl.Message(content="Analisando sua solicitação...")
|
|
||||||
await msg_routing.send()
|
|
||||||
|
|
||||||
current_crew = SmartRouter.route(user_input)
|
current_crew = SmartRouter.route(user_input)
|
||||||
cl.user_session.set("selected_crew", current_crew)
|
cl.user_session.set("selected_crew", current_crew)
|
||||||
|
|
||||||
await msg_routing.update()
|
# 3. Execution - show only thinking indicator
|
||||||
await cl.Message(content=f"**Direcionando para:** {current_crew}").send()
|
msg = cl.Message(content="Pensando...", author="Gnarl")
|
||||||
|
|
||||||
# 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...")
|
|
||||||
await msg.send()
|
await msg.send()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -57,12 +50,12 @@ async def on_message(message: cl.Message):
|
||||||
result = crew.kickoff(inputs={"topic": user_input})
|
result = crew.kickoff(inputs={"topic": user_input})
|
||||||
final_answer = str(result)
|
final_answer = str(result)
|
||||||
|
|
||||||
# Update message with final result
|
# Update message with clean result (no crew info)
|
||||||
msg.content = f"### Relatório de {current_crew}\n\n{final_answer}"
|
msg.content = final_answer
|
||||||
await msg.update()
|
await msg.update()
|
||||||
|
|
||||||
except Exception as e:
|
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()
|
await msg.update()
|
||||||
# Reset crew on failure so user can try again or get re-routed
|
# Reset crew on failure so user can try again or get re-routed
|
||||||
cl.user_session.set("selected_crew", None)
|
cl.user_session.set("selected_crew", None)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue