diff options
Diffstat (limited to 'agent/orchestrator/api.py')
| -rw-r--r-- | agent/orchestrator/api.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/agent/orchestrator/api.py b/agent/orchestrator/api.py index e91ea36..39d1409 100644 --- a/agent/orchestrator/api.py +++ b/agent/orchestrator/api.py @@ -4,15 +4,27 @@ Open WebUI (and other OpenAI-API clients) talks to this endpoint set. We accept the standard `/v1/chat/completions` shape, translate to internal types, hand off to the orchestrator, and translate the response back to OpenAI shape. """ +import asyncio +from contextlib import asynccontextmanager from fastapi import FastAPI, HTTPException, Request from pydantic import BaseModel, ConfigDict from .loop import handle_turn +from .matrix_bot import run as matrix_run from .models import Message -app = FastAPI(title="Sénia") +@asynccontextmanager +async def lifespan(app: FastAPI): + task = asyncio.create_task(matrix_run()) + try: + yield + finally: + task.cancel() + + +app = FastAPI(title="Sénia", lifespan=lifespan) class ChatMessage(BaseModel): |
