daisy-rrhh-backend / client_chat.py
Freight's picture
pr/42 (#1)
bc9904d verified
Raw
History Blame Contribute Delete
809 Bytes
import requests
print("💬 Chat con streaming (escribe 'salir' para terminar)")
print("======================================================")
agents = ["rrhh", "tms"]
agent_id = input("Agente a usar (rrhh o tms): ")
while True:
if agent_id not in agents:
print("No existe un agente el agente")
else:
question = input("Tú: ")
if question.lower() in ["salir", "exit", "quit"]:
print("👋 Fin del chat.")
break
with requests.post("http://127.0.0.1:7860/ask-stream", json={"agent_id": agent_id, "question": question}, stream=True) as r:
print("Asistente: ", end="", flush=True)
for chunk in r.iter_content(chunk_size=None):
print(chunk.decode("utf-8"), end="", flush=True)
print()