From 3113110c36e0a0352d8b5ba6222ea04b8087ec17 Mon Sep 17 00:00:00 2001 From: Guillermo Serrahima Date: Thu, 2 Jul 2026 09:23:54 +0200 Subject: Added matrix comm channel --- agent/orchestrator/api.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'agent/orchestrator/api.py') 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): -- cgit v1.2.3