File size: 847 Bytes
70ddaa3 f4146f5 70ddaa3 f4146f5 70ddaa3 f4146f5 70ddaa3 f4146f5 70ddaa3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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.
"""
|