import type { ArticleInput, CandidateFactCard } from "../domain/types";
import { candidateFactCardSchema } from "../domain/validation";
import { generateValidatedJson } from "../llm/client";
import {
  FACT_EXTRACTOR_SYSTEM_PROMPT,
  buildFactExtractorPrompt,
} from "../llm/prompts";

export async function extractCandidateFactCard(
  input: ArticleInput,
): Promise<CandidateFactCard> {
  return generateValidatedJson({
    schema: candidateFactCardSchema,
    system: FACT_EXTRACTOR_SYSTEM_PROMPT,
    prompt: buildFactExtractorPrompt(input),
    temperature: 0.1,
    task: "fact_extractor",
  });
}
