Update schema.py
Browse files
schema.py
CHANGED
|
@@ -1,49 +1,13 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
from typing import List, Optional
|
| 4 |
-
|
| 5 |
-
class TimelineItem(BaseModel):
|
| 6 |
-
date: str = Field(..., description="YYYY-MM-DD")
|
| 7 |
-
event: str
|
| 8 |
-
source: str
|
| 9 |
-
|
| 10 |
-
class OpportunityItem(BaseModel):
|
| 11 |
-
name: str
|
| 12 |
-
stage: str
|
| 13 |
-
amount: float
|
| 14 |
-
closeDate: Optional[str] = None
|
| 15 |
-
nextStep: Optional[str] = None
|
| 16 |
|
| 17 |
class PreCallSummary(BaseModel):
|
| 18 |
-
client_overview: str
|
| 19 |
-
relationship_timeline:
|
| 20 |
-
open_items:
|
| 21 |
-
opportunities:
|
| 22 |
-
risks_flags:
|
| 23 |
-
recommendations:
|
| 24 |
-
pre_call_questions:
|
| 25 |
-
sources:
|
| 26 |
-
|
| 27 |
-
def ensure_schema(d: dict) -> PreCallSummary:
|
| 28 |
-
"""Validate and coerce a dict to PreCallSummary, filling missing keys with safe defaults."""
|
| 29 |
-
defaults = {
|
| 30 |
-
"client_overview": "",
|
| 31 |
-
"relationship_timeline": [],
|
| 32 |
-
"open_items": [],
|
| 33 |
-
"opportunities": [],
|
| 34 |
-
"risks_flags": [],
|
| 35 |
-
"recommendations": [],
|
| 36 |
-
"pre_call_questions": [],
|
| 37 |
-
"sources": []
|
| 38 |
-
}
|
| 39 |
-
merged = {**defaults, **(d or {})}
|
| 40 |
-
try:
|
| 41 |
-
return PreCallSummary.model_validate(merged)
|
| 42 |
-
except ValidationError as e:
|
| 43 |
-
# Best-effort repair for common issues
|
| 44 |
-
for fld in ["relationship_timeline", "open_items", "opportunities", "risks_flags", "recommendations", "pre_call_questions", "sources"]:
|
| 45 |
-
if merged.get(fld) is None:
|
| 46 |
-
merged[fld] = []
|
| 47 |
-
if merged.get("client_overview") is None:
|
| 48 |
-
merged["client_overview"] = ""
|
| 49 |
-
return PreCallSummary.model_validate(merged)
|
|
|
|
| 1 |
+
from pydantic import BaseModel
|
| 2 |
+
from typing import Optional
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
class PreCallSummary(BaseModel):
|
| 5 |
+
client_overview: Optional[str] = None
|
| 6 |
+
relationship_timeline: Optional[str] = None
|
| 7 |
+
open_items: Optional[str] = None
|
| 8 |
+
opportunities: Optional[str] = None
|
| 9 |
+
risks_flags: Optional[str] = None
|
| 10 |
+
recommendations: Optional[str] = None
|
| 11 |
+
pre_call_questions: Optional[str] = None
|
| 12 |
+
sources: Optional[str] = None
|
| 13 |
+
summary: Optional[str] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|