"""Abstract base model for ADFMentor evaluators."""

from abc import ABC, abstractmethod
from typing import Any, Dict


def build_content(questions: str, adf_data: str, prompt: str) -> str:
    """Build the evaluation prompt for ADF pipeline evaluations.

    The AI receives the full lecture questions (all tasks), the parsed
    ADF JSON data, and evaluation instructions.  It must identify which
    task each submitted file belongs to and evaluate accordingly.

    Args:
        questions: Full lecture task descriptions (all tasks)
        adf_data: Parsed ADF JSON data (one or multiple files)
        prompt: Evaluation instructions

    Returns:
        Formatted prompt string
    """
    return f"""
            Instruction:
            {prompt.strip()}

            You are given the full lecture task descriptions below.
            The student may have submitted one or more ADF JSON files.
            For EACH submitted file, identify which task it belongs to,
            then evaluate it against that task's requirements.

            Lecture Tasks / Questions:
            {questions.strip()}

            Student Submission (parsed ADF JSON):
            {adf_data.strip()}

            Return ONLY valid JSON in the following format.
            DO NOT add explanations, markdown, or extra text.
            DO NOT wrap in ```.

            JSON schema:
            {{
              "score": number (0-100, overall average),
              "feedback": string (overall summary),
              "task_mapping": [
                {{
                  "file": string (source filename),
                  "identified_task": string (which task this file matches),
                  "score": number (0-100),
                  "feedback": string
                }}
              ]
            }}
    """.strip()


class Model(ABC):
    """Abstract base class for AI model evaluators.

    All model implementations must inherit from this class and implement
    the evaluate method.
    """

    def __init__(self):
        """Initialize the model."""
        pass

    @abstractmethod
    def evaluate(self, questions: str, adf_data: str, prompt: str) -> Dict[str, Any]:
        """Evaluate ADF submission(s) against lecture tasks using AI.

        Args:
            questions: Full lecture task descriptions
            adf_data: Parsed ADF JSON data
            prompt: Evaluation criteria and instructions for the model

        Returns:
            Dictionary with 'score' (0-100), 'feedback' (string),
            and 'task_mapping' (list of per-task results)
        """
        pass
