Add project registry refresh foundation
This commit is contained in:
@@ -33,6 +33,10 @@ from atocore.memory.service import (
|
||||
update_memory,
|
||||
)
|
||||
from atocore.observability.logger import get_logger
|
||||
from atocore.projects.registry import (
|
||||
list_registered_projects,
|
||||
refresh_registered_project,
|
||||
)
|
||||
from atocore.retrieval.retriever import retrieve
|
||||
from atocore.retrieval.vector_store import get_vector_store
|
||||
|
||||
@@ -55,6 +59,14 @@ class IngestSourcesResponse(BaseModel):
|
||||
results: list[dict]
|
||||
|
||||
|
||||
class ProjectRefreshResponse(BaseModel):
|
||||
project: str
|
||||
aliases: list[str]
|
||||
description: str
|
||||
purge_deleted: bool
|
||||
roots: list[dict]
|
||||
|
||||
|
||||
class QueryRequest(BaseModel):
|
||||
prompt: str
|
||||
top_k: int = 10
|
||||
@@ -148,6 +160,28 @@ def api_ingest_sources() -> IngestSourcesResponse:
|
||||
return IngestSourcesResponse(results=results)
|
||||
|
||||
|
||||
@router.get("/projects")
|
||||
def api_projects() -> dict:
|
||||
"""Return registered projects and their resolved ingest roots."""
|
||||
return {
|
||||
"projects": list_registered_projects(),
|
||||
"registry_path": str(_config.settings.resolved_project_registry_path),
|
||||
}
|
||||
|
||||
|
||||
@router.post("/projects/{project_name}/refresh", response_model=ProjectRefreshResponse)
|
||||
def api_refresh_project(project_name: str, purge_deleted: bool = False) -> ProjectRefreshResponse:
|
||||
"""Refresh one registered project from its configured ingest roots."""
|
||||
try:
|
||||
result = refresh_registered_project(project_name, purge_deleted=purge_deleted)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
except Exception as e:
|
||||
log.error("project_refresh_failed", project=project_name, error=str(e))
|
||||
raise HTTPException(status_code=500, detail=f"Project refresh failed: {e}")
|
||||
return ProjectRefreshResponse(**result)
|
||||
|
||||
|
||||
@router.post("/query", response_model=QueryResponse)
|
||||
def api_query(req: QueryRequest) -> QueryResponse:
|
||||
"""Retrieve relevant chunks for a prompt."""
|
||||
|
||||
Reference in New Issue
Block a user