feat: FlowPilot AI — Phases 4 & 5 (Gallery, Export, Responsive, Enterprise, Analytics) #116
@@ -645,16 +645,33 @@ async def get_session(
|
||||
confidence_score=step.confidence_at_step,
|
||||
))
|
||||
|
||||
try:
|
||||
detail = AISessionDetail.model_validate(session)
|
||||
detail.steps = step_responses
|
||||
return detail
|
||||
except Exception as e:
|
||||
logger.exception("Failed to serialize session %s: %s", session_id, e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Session serialization error: {type(e).__name__}: {str(e)[:200]}",
|
||||
)
|
||||
# Build detail manually — AISessionDetail.model_validate(session) fails because
|
||||
# the ORM relationship 'steps' has 'id' not 'step_id', causing validation errors.
|
||||
# Instead, extract non-step fields from ORM and set step_responses separately.
|
||||
detail = AISessionDetail(
|
||||
id=session.id,
|
||||
status=session.status,
|
||||
intake_type=session.intake_type,
|
||||
intake_content=session.intake_content or {},
|
||||
problem_summary=session.problem_summary,
|
||||
problem_domain=session.problem_domain,
|
||||
confidence_tier=session.confidence_tier,
|
||||
step_count=session.step_count,
|
||||
session_rating=session.session_rating,
|
||||
psa_ticket_id=session.psa_ticket_id,
|
||||
psa_connection_id=session.psa_connection_id,
|
||||
escalation_reason=session.escalation_reason,
|
||||
matched_flow_id=session.matched_flow_id,
|
||||
match_score=getattr(session, 'match_score', None),
|
||||
resolution_summary=session.resolution_summary,
|
||||
resolution_action=getattr(session, 'resolution_action', None),
|
||||
session_feedback=session.session_feedback,
|
||||
ticket_data=session.ticket_data,
|
||||
created_at=session.created_at,
|
||||
resolved_at=session.resolved_at,
|
||||
steps=step_responses,
|
||||
)
|
||||
return detail
|
||||
|
||||
|
||||
# ── Documentation ──
|
||||
|
||||
Reference in New Issue
Block a user