Sage / scripts /lib /services.py
vxa8502's picture
Add docker-compose, multi-stage builds, and developer tooling
d507c32
raw
history blame contribute delete
761 Bytes
"""Shared service initialization for scripts."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from sage.adapters.hhem import HallucinationDetector
from sage.services.explanation import Explainer
def get_explanation_services() -> tuple[Explainer, HallucinationDetector]:
"""Initialize Explainer and HallucinationDetector.
Centralizes the common pattern of creating both services together.
Import is deferred to avoid loading heavy models until needed.
Returns:
Tuple of (Explainer, HallucinationDetector) instances.
"""
from sage.adapters.hhem import HallucinationDetector
from sage.services.explanation import Explainer
return Explainer(), HallucinationDetector()