agromatrix: add shared-memory review api and crawl4ai robustness
This commit is contained in:
@@ -1228,6 +1228,13 @@ class InferResponse(BaseModel):
|
||||
file_mime: Optional[str] = None
|
||||
|
||||
|
||||
class SharedMemoryReviewRequest(BaseModel):
|
||||
point_id: str
|
||||
approve: bool
|
||||
reviewer: Optional[str] = None
|
||||
note: Optional[str] = None
|
||||
|
||||
|
||||
|
||||
|
||||
# =========================================================================
|
||||
@@ -2870,6 +2877,40 @@ async def list_available_models():
|
||||
return {"models": models, "total": len(models)}
|
||||
|
||||
|
||||
@app.get("/v1/agromatrix/shared-memory/pending")
|
||||
async def agromatrix_shared_pending(limit: int = 50):
|
||||
"""List pending shared agronomy memory cases for mentor review."""
|
||||
if not MEMORY_RETRIEVAL_AVAILABLE or not memory_retrieval:
|
||||
raise HTTPException(status_code=503, detail="Memory retrieval not available")
|
||||
if not hasattr(memory_retrieval, "list_shared_pending_cases"):
|
||||
raise HTTPException(status_code=501, detail="Pending review API not enabled")
|
||||
items = await memory_retrieval.list_shared_pending_cases(limit=limit)
|
||||
return {"items": items, "total": len(items)}
|
||||
|
||||
|
||||
@app.post("/v1/agromatrix/shared-memory/review")
|
||||
async def agromatrix_shared_review(req: SharedMemoryReviewRequest):
|
||||
"""Approve or reject a pending shared agronomy memory case."""
|
||||
if not MEMORY_RETRIEVAL_AVAILABLE or not memory_retrieval:
|
||||
raise HTTPException(status_code=503, detail="Memory retrieval not available")
|
||||
if not hasattr(memory_retrieval, "review_shared_pending_case"):
|
||||
raise HTTPException(status_code=501, detail="Review API not enabled")
|
||||
|
||||
result = await memory_retrieval.review_shared_pending_case(
|
||||
point_id=req.point_id,
|
||||
approve=req.approve,
|
||||
reviewer=req.reviewer,
|
||||
note=req.note,
|
||||
)
|
||||
if not isinstance(result, dict):
|
||||
raise HTTPException(status_code=500, detail="Invalid review result")
|
||||
if result.get("ok"):
|
||||
return result
|
||||
if result.get("error") == "not_found":
|
||||
raise HTTPException(status_code=404, detail="Pending case not found")
|
||||
raise HTTPException(status_code=500, detail=result.get("error", "review_failed"))
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# NEO4J GRAPH API ENDPOINTS
|
||||
# =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user