88a1dab810
---ci--- phase: 7 milestone: v0.2 status: complete requirements: covered: [REQ-2-001, REQ-2-002, REQ-2-003, REQ-2-004, REQ-2-005, REQ-2-006, REQ-2-007, REQ-2-008, REQ-2-009, REQ-2-010, REQ-2-011, REQ-2-012] partial: [] ---/ci--- Milestone v0.2 (ai-tutor-architecture) merged to main. Escalation record (audit remediation, durable): P1 executor delegation failed twice (empty subagent results, zero files created); auto-resolved at full autonomy to inline execution with identical plan fidelity (commit 3271373, reflog-only after phase branch squash-delete).
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""POST /v1/assessment/evaluate — structured rubric scores (REQ-2-008).
|
|
|
|
JSON response (not SSE): a pydantic-validated RubricScore. Unknown
|
|
artifact → 404. The Assessor's structured output IS the payload.
|
|
"""
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
from pydantic import BaseModel, Field
|
|
|
|
from ..agents.assessor import RubricScore
|
|
from ..agents.registry import AgentRegistry
|
|
from ..config import Settings
|
|
from ..corpus.artifacts import get_artifact_bundle, get_transcript_for_artifact
|
|
from ..corpus.learner_context import get_learner_context
|
|
from .deps import get_agent_registry, get_provider, get_settings
|
|
|
|
router = APIRouter(prefix="/v1")
|
|
|
|
|
|
class AssessmentRequest(BaseModel):
|
|
artifact_id: str = Field(min_length=1)
|
|
learner_id: str | None = None
|
|
|
|
|
|
@router.post("/assessment/evaluate", response_model=RubricScore)
|
|
async def assessment_evaluate(
|
|
body: AssessmentRequest,
|
|
registry: AgentRegistry = Depends(get_agent_registry),
|
|
settings: Settings = Depends(get_settings),
|
|
provider=Depends(get_provider),
|
|
) -> RubricScore:
|
|
bundle = get_artifact_bundle(body.artifact_id)
|
|
if bundle is None:
|
|
raise HTTPException(
|
|
status_code=404, detail=f"unknown artifact {body.artifact_id!r}"
|
|
)
|
|
artifact, rubric = bundle
|
|
transcript = get_transcript_for_artifact(artifact.artifact_id)
|
|
agent = registry.get(provider, settings, "assessor")
|
|
learner_context = get_learner_context(body.learner_id)
|
|
try:
|
|
return await agent.evaluate(artifact, rubric, transcript, learner_context)
|
|
except Exception as exc:
|
|
raise HTTPException(
|
|
status_code=502,
|
|
detail=f"assessment evaluation failed: {exc}",
|
|
) from exc
|