68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
"""API endpoints for AIOS Search Gateway."""
|
|
|
|
from typing import Any
|
|
|
|
try:
|
|
from fastapi import APIRouter
|
|
except Exception:
|
|
APIRouter = None
|
|
|
|
from .search_gateway import SearchRequest
|
|
from .search_gateway_orchestrator import SearchGatewayOrchestrator
|
|
from .trace_tool_credential_governance import GovernanceActor, TraceContext
|
|
from .search_gateway_dashboard import SearchGatewayDashboard
|
|
|
|
|
|
orchestrator = SearchGatewayOrchestrator()
|
|
dashboard = SearchGatewayDashboard()
|
|
|
|
|
|
def search_gateway_request(payload: dict[str, Any], *, actor: GovernanceActor | dict[str, Any] | None = None, trace: TraceContext | None = None) -> dict[str, Any]:
|
|
return orchestrator.execute(payload, actor=actor, trace=trace)
|
|
|
|
|
|
def get_search_gateway_status() -> dict[str, Any]:
|
|
return {
|
|
"module": "search-gateway",
|
|
"status": "ready",
|
|
"providers_configured": len(orchestrator.gateway.providers),
|
|
"policy_guard": "enabled",
|
|
"profile_customization": "enabled",
|
|
"fallback_required_when_provider_unavailable": True,
|
|
"governance": "required",
|
|
}
|
|
|
|
|
|
def get_search_gateway_overview() -> dict[str, Any]:
|
|
return dashboard.overview()
|
|
|
|
|
|
def build_router():
|
|
if APIRouter is None:
|
|
return None
|
|
router = APIRouter(prefix="/admin/ai-evolution/search", tags=["search-gateway"])
|
|
|
|
@router.get("/status", operation_id="getSearchGatewayStatus")
|
|
def status():
|
|
return get_search_gateway_status()
|
|
|
|
@router.get("/overview", operation_id="getSearchGatewayOverview")
|
|
def overview():
|
|
return get_search_gateway_overview()
|
|
|
|
@router.post("/query", operation_id="runSearchGatewayQuery")
|
|
def query(payload: dict[str, Any]):
|
|
return search_gateway_request(payload)
|
|
|
|
return router
|
|
|
|
|
|
router = build_router()
|
|
|
|
__all__ = [
|
|
"router",
|
|
"search_gateway_request",
|
|
"get_search_gateway_status",
|
|
"get_search_gateway_overview",
|
|
]
|