from transformers import pipeline from schema import PreCallSummary class PreCallSummaryModel: def __init__(self): # Load FLAN-T5 locally instead of via HF Inference API self.generator = pipeline("text2text-generation", model="google/flan-t5-base") def generate(self, context: dict) -> PreCallSummary: prompt = self._build_prompt(context) result = self.generator(prompt, max_length=512, do_sample=False) summary_text = result[0]["generated_text"] return PreCallSummary(summary=summary_text) def _build_prompt(self, ctx: dict) -> str: return f""" You are a helpful assistant. Generate a professional pre-call summary based on this Salesforce account context: {ctx} Format the output as a concise summary suitable for a sales rep. """