diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-07-02 09:23:54 +0200 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-07-02 09:23:54 +0200 |
| commit | 3113110c36e0a0352d8b5ba6222ea04b8087ec17 (patch) | |
| tree | 4f64efb5a011314ddf19b8b6b2da6796b5659977 /agent/orchestrator/api.py | |
| parent | 782d2e71295a2f92f1d349c8323878e81f371359 (diff) | |
| download | senia-3113110c36e0a0352d8b5ba6222ea04b8087ec17.tar.xz senia-3113110c36e0a0352d8b5ba6222ea04b8087ec17.zip | |
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): |
