Skip to content

Commit 3c46310

Browse files
author
hfhoffman1144
committed
tr update
1 parent d53bc8f commit 3c46310

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

python-langgraph/chains/notice_extraction.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,23 @@ class NoticeEmailExtract(BaseModel):
6161
(if any)""",
6262
)
6363

64-
@computed_field
65-
@property
66-
def date_of_notice(self) -> date | None:
64+
@staticmethod
65+
def _convert_string_to_date(date: str | None) -> date | None:
6766
try:
68-
return datetime.strptime(
69-
self.date_of_notice_str, "%Y-%m-%d"
70-
).date()
67+
return datetime.strptime(date, "%Y-%m-%d").date()
7168
except Exception as e:
7269
print(e)
7370
return None
7471

72+
@computed_field
73+
@property
74+
def date_of_notice(self) -> date | None:
75+
return self._convert_string_to_date(self.date_of_notice_str)
76+
7577
@computed_field
7678
@property
7779
def compliance_deadline(self) -> date | None:
78-
try:
79-
return datetime.strptime(
80-
self.compliance_deadline_str, "%Y-%m-%d"
81-
).date()
82-
except Exception as e:
83-
print(e)
84-
return None
80+
return self._convert_string_to_date(self.compliance_deadline_str)
8581

8682

8783
info_parse_prompt = ChatPromptTemplate.from_messages(

0 commit comments

Comments
 (0)