from geood.result import DetectionResult
from geood.detector import Detector

__version__ = "0.1.0"


def calibrate(model, ref_texts, tokenizer=None, layer="auto"):
    """Calibrate an OOD detector from reference in-distribution texts.

    Args:
        model: HuggingFace model name (str) or loaded PreTrainedModel object.
        ref_texts: List of in-distribution reference texts.
        tokenizer: Required when model is an object. Ignored when model is a string.
        layer: "auto" (default) to auto-select best layer, or int for manual override.

    Returns:
        Detector: Calibrated detector ready for detect() calls.
    """
    detector = Detector()
    detector.calibrate(model, ref_texts, tokenizer=tokenizer, layer=layer)
    return detector


def load(path):
    """Load a previously saved detector.

    Args:
        path: Path to .geood file.

    Returns:
        Detector: Loaded detector ready for detect() calls.
    """
    return Detector.load(path)


__all__ = ["calibrate", "load", "DetectionResult", "Detector"]
