|
|
| SCHEMA_TEXT = """ |
| Return JSON with EXACTLY these keys: |
| { |
| "client_overview": str, |
| "relationship_timeline": [ |
| {"date":"YYYY-MM-DD","event":"...", "source":"Case|Opportunity|Task|Activity|Other"} |
| ], |
| "open_items": [str], |
| "opportunities": [ |
| {"name":"...", "stage":"...", "amount": number, "closeDate":"YYYY-MM-DD or null", "nextStep":"..."} |
| ], |
| "risks_flags": [str], |
| "recommendations": [str], |
| "pre_call_questions": [str], |
| "sources": [str] |
| } |
| """ |
|
|
| FEW_SHOT = [ |
| { |
| "context": { |
| "account": {"Id":"001X","Name":"Acme Corp","Industry":"Manufacturing","Type":"Customer-Direct","Rating":"Hot","AnnualRevenue": 45000000}, |
| "opportunities": [ |
| {"Id":"006A","Name":"Q4 Renewal","StageName":"Negotiation","Amount": 2000000, "CloseDate":"2025-09-30", "NextStep":"Legal review"}, |
| {"Id":"006B","Name":"Cross-sell Treasury","StageName":"Qualification","Amount": 500000, "CloseDate":"2025-10-15", "NextStep":"Intro call"} |
| ], |
| "cases": [ |
| {"Id":"500C","CaseNumber":"000123","Subject":"Payment delay","Status":"In Progress","Priority":"High","Origin":"Phone","LastModifiedDate":"2025-08-01T12:00:00Z"} |
| ], |
| "activities": [ |
| {"Id":"00T1","Subject":"Quarterly check-in","ActivityDate":"2025-07-15","Status":"Completed","Owner":{"Alias":"jdoe"}} |
| ] |
| }, |
| "output": { |
| "client_overview": "Acme Corp (Manufacturing, Customer-Direct). Est. revenue $45M. Relationship rated Hot.", |
| "relationship_timeline": [ |
| {"date":"2025-08-01","event":"High-priority case: Payment delay is in progress.","source":"Case"}, |
| {"date":"2025-07-15","event":"Completed quarterly check-in.","source":"Activity"} |
| ], |
| "open_items": ["Follow up on payment delay case"], |
| "opportunities": [ |
| {"name":"Q4 Renewal","stage":"Negotiation","amount":2000000,"closeDate":"2025-09-30","nextStep":"Legal review"}, |
| {"name":"Cross-sell Treasury","stage":"Qualification","amount":500000,"closeDate":"2025-10-15","nextStep":"Intro call"} |
| ], |
| "risks_flags": ["Open high-priority service issue may affect renewal"], |
| "recommendations": ["Confirm payment issue resolution","Schedule renewal legal review","Propose treasury intro"], |
| "pre_call_questions": ["Who is sponsor for renewal?","Any blockers from finance?","Treasury appetite and timeline?"], |
| "sources": ["Account:001X","Opportunity:006A","Opportunity:006B","Case:500C","Task:00T1"] |
| } |
| } |
| ] |
|
|
| def build_prompt(context_json: str) -> str: |
| |
| parts = [] |
| parts.append("You are a banking relationship assistant. Summarize pre-call context for the given Account.") |
| parts.append("Be concise and factual. If data is missing, say 'Unknown' briefly. Output STRICT JSON only.") |
| parts.append(SCHEMA_TEXT) |
| parts.append("Here is a worked example:") |
| parts.append("Context: " + str(FEW_SHOT[0]["context"])) |
| parts.append("Output JSON: " + str(FEW_SHOT[0]["output"])) |
| parts.append("Now produce output for this Context:") |
| parts.append(context_json) |
| parts.append("Output JSON only:") |
| return "\n\n".join(parts) |