import { classify } from "./classifier";
import type { InferenceRequest } from "../shared/types";

self.onmessage = async (event: MessageEvent<{ requests: InferenceRequest[]; modelBaseUrl: string }>) => {
  try {
    const results = await classify(event.data.requests, event.data.modelBaseUrl);
    self.postMessage({ results });
  } catch (error) {
    self.postMessage({ error: error instanceof Error ? error.message : String(error) });
  }
};
