"""
Deterministic evaluation — no LLM judge needed.

Demonstrates evalkit's deterministic text metrics that run locally without
any API keys or judge configuration. Useful for CI pipelines, quick checks,
and ground-truth comparison.

Usage:
    python examples/deterministic.py
"""

from __future__ import annotations

from evalkit import (
    AnswerSimilaritySuite,
    EvaluationEngine,
    ExactMatchMetric,
    TestCase,
)
from evalkit.metrics.rouge import RougeMetric
from evalkit.metrics.string_similarity import StringSimilarityMetric

# Test cases with expected answers (ground truth)
TEST_CASES = [
    TestCase(
        question="What is the capital of France?",
        answer="The capital of France is Paris.",
        expected_answer="Paris",
    ),
    TestCase(
        question="Who created Python?",
        answer="Python was created by Guido van Rossum.",
        expected_answer="Guido van Rossum",
    ),
    TestCase(
        question="What year was the first iPhone released?",
        answer="The first iPhone was released in 2007.",
        expected_answer="2007",
    ),
    TestCase(
        question="What is the speed of light?",
        answer="The speed of light is approximately 300,000 km/s.",
        expected_answer="299,792,458 meters per second",
    ),
]


def main() -> None:
    print("=== AnswerSimilaritySuite (no judge needed) ===\n")

    # No judge required — pass None or omit entirely
    engine = EvaluationEngine()
    report = engine.run(test_cases=TEST_CASES, suite=AnswerSimilaritySuite())
    report.print_report()

    print("\n=== Custom metric mix (individual deterministic metrics) ===\n")

    metrics = [
        ExactMatchMetric(),
        StringSimilarityMetric(threshold=0.6),
    ]

    # ROUGE is optional — include if installed
    try:
        metrics.append(RougeMetric())
        print("(ROUGE metric included — evalkit[rouge] installed)")
    except ImportError:
        print("(ROUGE metric skipped — install with: pip install evalkit-llm[rouge])")

    print()
    report = engine.run(test_cases=TEST_CASES, metrics=metrics)
    report.print_report()


if __name__ == "__main__":
    main()
