forked from sagnik/Project_Velocity
Feat: CRM v2, Richer synthetic data, Canvas JSON Components
This commit is contained in:
@@ -4,6 +4,7 @@ from fastapi import APIRouter, HTTPException, Request
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from backend.oracle.action_service import oracle_action_service
|
||||
from backend.oracle.natural_db_agent import natural_db_agent
|
||||
from backend.oracle.persona_service import persona_service
|
||||
from backend.services.mcp_registry import mcp_registry
|
||||
from backend.services.nemoclaw_runtime import nemoclaw_runtime
|
||||
@@ -33,6 +34,12 @@ class OracleWritebackRequest(BaseModel):
|
||||
writeback_payload: dict = Field(default_factory=dict)
|
||||
|
||||
|
||||
class OracleQueryRequest(BaseModel):
|
||||
prompt: str = Field(..., min_length=1, max_length=4096)
|
||||
row_limit: int = Field(default=100, ge=1, le=500)
|
||||
context: dict = Field(default_factory=dict)
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def oracle_health() -> dict:
|
||||
return {
|
||||
@@ -43,6 +50,39 @@ async def oracle_health() -> dict:
|
||||
}
|
||||
|
||||
|
||||
@router.get("/data-health")
|
||||
async def oracle_data_health(request: Request) -> dict:
|
||||
pool = getattr(request.app.state, "db_pool", None)
|
||||
if pool is None:
|
||||
raise HTTPException(status_code=503, detail="Database unavailable.")
|
||||
async with pool.acquire() as conn:
|
||||
data = await natural_db_agent.data_health(conn)
|
||||
return {
|
||||
"status": "ok",
|
||||
"data": data,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/schema-catalog")
|
||||
async def oracle_schema_catalog(request: Request) -> dict:
|
||||
pool = getattr(request.app.state, "db_pool", None)
|
||||
if pool is None:
|
||||
raise HTTPException(status_code=503, detail="Database unavailable.")
|
||||
async with pool.acquire() as conn:
|
||||
catalog = await natural_db_agent.schema_catalog(conn)
|
||||
return {"status": "ok", "data": catalog}
|
||||
|
||||
|
||||
@router.post("/query")
|
||||
async def oracle_query(request: Request, payload: OracleQueryRequest) -> dict:
|
||||
pool = getattr(request.app.state, "db_pool", None)
|
||||
if pool is None:
|
||||
raise HTTPException(status_code=503, detail="Database unavailable.")
|
||||
async with pool.acquire() as conn:
|
||||
result = await natural_db_agent.execute_prompt(payload.prompt, row_limit=payload.row_limit, conn=conn)
|
||||
return {"status": "ok", "data": result.as_dict()}
|
||||
|
||||
|
||||
@router.get("/mcp/tools")
|
||||
async def oracle_mcp_tools() -> dict:
|
||||
return {"status": "ok", "data": mcp_registry.list_tools()}
|
||||
|
||||
Reference in New Issue
Block a user