Spaces:
Configuration error
Configuration error
| from fastapi import APIRouter | |
| from fastapi.responses import JSONResponse | |
| from ..models import ChatHistoryClearResponse, ChatHistoryResponse, ChatRequest | |
| from ..services import get_conversation_log, get_trigger_service, handle_chat_request | |
| router = APIRouter(prefix="/chat", tags=["chat"]) | |
| # Handle incoming chat messages and route them to the interaction agent | |
| async def chat_send( | |
| payload: ChatRequest, | |
| ) -> JSONResponse: | |
| return await handle_chat_request(payload) | |
| # Retrieve the conversation history from the log | |
| def chat_history() -> ChatHistoryResponse: | |
| log = get_conversation_log() | |
| return ChatHistoryResponse(messages=log.to_chat_messages()) | |
| def clear_history() -> ChatHistoryClearResponse: | |
| from ..services import get_execution_agent_logs, get_agent_roster | |
| # Clear conversation log | |
| log = get_conversation_log() | |
| log.clear() | |
| # Clear execution agent logs | |
| execution_logs = get_execution_agent_logs() | |
| execution_logs.clear_all() | |
| # Clear agent roster | |
| roster = get_agent_roster() | |
| roster.clear() | |
| # Clear stored triggers | |
| trigger_service = get_trigger_service() | |
| trigger_service.clear_all() | |
| return ChatHistoryClearResponse() | |
| __all__ = ["router"] | |