feat: land page aggregate and phase7 document ai mainline

- 收口 page aggregate 读取、本地状态与命令客户端\n- 接入 phase7 document ai sidecar 与前端编排入口\n- 更新 architecture 与 design 状态迁移
This commit is contained in:
lix-2026
2026-04-23 07:38:34 +08:00
parent 8353aea2f9
commit 41e958769e
93 changed files with 8778 additions and 2222 deletions
+3
View File
@@ -22,6 +22,9 @@ class Settings(BaseSettings):
redis_url: str = "redis://localhost:6379/0"
frontend_url: str = "http://localhost:3000"
openai_api_key: str = ""
mnote_ai_default_model: str = ""
mnote_ai_orchestrator_api_key: str = ""
openai_agents_session_db_path: str = ""
lightrag_db_url: str = ""
lightrag_collection: str = "wolai-docs"
+6 -5
View File
@@ -1,10 +1,11 @@
from fastapi import APIRouter
from . import chat, health, luckysheet_ws, tasks
api_router = APIRouter(prefix="/api/v1")
api_router.include_router(tasks.router, tags=["tasks"])
api_router.include_router(chat.router, tags=["chat"])
from . import ai_agent, chat, health, luckysheet_ws, tasks
api_router = APIRouter(prefix="/api/v1")
api_router.include_router(tasks.router, tags=["tasks"])
api_router.include_router(chat.router, tags=["chat"])
api_router.include_router(ai_agent.router, tags=["ai-agent"])
root_router = APIRouter()
root_router.include_router(health.router, tags=["health"])
+64
View File
@@ -0,0 +1,64 @@
from __future__ import annotations
from typing import Annotated
from fastapi import APIRouter, Depends, Header, HTTPException, Request, status
from fastapi.responses import JSONResponse, StreamingResponse
from app.config import settings
from app.services.ai_document_agent import (
DocumentAiRunRequest,
build_document_ai_config_payload,
has_configured_openai_api_key,
run_document_agent_stream,
sdk_available,
)
router = APIRouter(prefix="/ai-agent")
def verify_internal_key(
x_mnote_ai_key: Annotated[str | None, Header()] = None,
) -> None:
expected = settings.mnote_ai_orchestrator_api_key.strip()
if not expected:
return
if x_mnote_ai_key == expected:
return
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid orchestrator key",
)
@router.get("/health")
async def health() -> JSONResponse:
return JSONResponse(
{
"ok": True,
"bridge": "openai_agents_python",
"sdkAvailable": sdk_available(),
"openaiConfigured": has_configured_openai_api_key(),
"bridgeRuntimeMode": "local_runtime",
}
)
@router.post("/document/run")
async def run_document(
request: Request,
payload: DocumentAiRunRequest,
_: None = Depends(verify_internal_key),
) -> StreamingResponse:
stream = run_document_agent_stream(
payload,
source_headers={key.lower(): value for key, value in request.headers.items()},
)
return StreamingResponse(stream, media_type="text/event-stream")
@router.get("/document/config")
async def get_document_config(
_: None = Depends(verify_internal_key),
) -> JSONResponse:
return JSONResponse(build_document_ai_config_payload())
File diff suppressed because it is too large Load Diff