import json
import os
from pathlib import Path
from typing import Any, Dict, List

from inference import model_fn, predict_fn
from internals.util.config import set_hf_cache_dir, set_model_config
from internals.util.model_loader import load_model_from_config


class EndpointHandler:
    def __init__(self, path=""):
        set_hf_cache_dir(Path.home() / ".cache" / "hf_cache")
        self.model_dir = path

        return model_fn(self.model_dir)

    def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
        return predict_fn(data, None)