from __future__ import annotations import json from http import HTTPStatus from backend.features.mentor.agent import MentorAgentError class MentorHttpMixin: def stream_mentor_chat(self) -> None: try: body = self.read_json_body() stream = self.application_service.mentor_stream(body) except (ValueError, json.JSONDecodeError) as exc: self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST) return self.send_ndjson_stream(stream, (ValueError, MentorAgentError))