"""Prompt template for LLM-powered failure analysis."""

from __future__ import annotations

TEMPLATE = """You are analyzing evaluation failures for the "{metric_name}" metric.

This metric measures: {metric_description}

The following test cases FAILED this metric. Analyze the failures and identify common patterns.

{failure_details}

Instructions:
1. Look for patterns across the failures (common topics, answer styles, context issues)
2. Identify the single most impactful fix the user could make to improve scores

Format your response as:
ANALYSIS: <your pattern analysis across failures>
PRIORITY FIX: <single most impactful fix to improve scores>

Set score to 0.0 — only the reason field matters here."""

METRIC_DESCRIPTIONS: dict[str, str] = {
    "faithfulness": "whether every claim in the answer is supported by the retrieved context",
    "answer_relevancy": "whether the response directly addresses the user's question",
    "contextual_relevancy": "whether the retrieved context is relevant to the question",
    "hallucination": "whether the answer contains facts NOT present in the context",
    "completeness": "whether the answer covers all key information from expected responses",
    "tool_selection": "whether the agent called the correct tools in the right order",
    "tool_parameter": "whether tool call parameters match expected values",
    "tool_parameter_similarity": "whether parameter values are semantically equivalent to expected",
    "exact_match": "whether the answer exactly matches the expected answer",
    "string_containment": "whether the answer contains the expected answer as a substring",
    "string_similarity": "normalized Levenshtein similarity between answer and expected answer",
    "bleu": "n-gram precision between answer and expected answer",
    "rouge": "n-gram recall between answer and expected answer",
}
