feat: Add NaliiaTools

This commit is contained in:
2026-02-16 16:35:15 -05:00
parent 63758f5f9c
commit 66fe0a2a13
7 changed files with 100 additions and 34 deletions

View File

@@ -1,18 +1,12 @@
import streamlit as st
from agent_client import AgentClient
from logger import logger
import json
import httpx
import random
import time
def response_generator(response: str = ""):
logger.info(f"Generating response stream for: {response}")
if response:
for word in response.split():
yield word + " "
time.sleep(0.05)
async def main():
st.image("src/ui/assets/logo-naliia.png", width=100, caption="NaliiaBot")
@@ -32,10 +26,23 @@ async def main():
agent_client = AgentClient()
response = await agent_client.send_message(prompt)
try:
response.raise_for_status()
data = response.json()
except json.JSONDecodeError:
raise RuntimeError(
f"Respuesta inválida (no JSON): {response.text}"
)
except httpx.HTTPStatusError as e:
raise RuntimeError(
f"Error HTTP {e.response.status_code}: {e.response.text}"
)
raw_response = response.json()['response']['messages'][-1]['content']
with st.chat_message("assistant"):
formated_response = st.markdown(raw_response)
st.session_state.messages.append({"role": "assistant", "content": formated_response})
st.session_state.messages.append({"role": "assistant", "content": raw_response})
if __name__ == "__main__": import asyncio; asyncio.run(main())