Skip to content

Commit 993674e

Browse files
author
hfhoffman1144
committed
tech review changes
1 parent 524f0b5 commit 993674e

File tree

7 files changed

+37
-25
lines changed

7 files changed

+37
-25
lines changed

python-langgraph/chains/binary_questions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ class BinaryAnswer(BaseModel):
2626
binary_question_model = ChatOpenAI(model="gpt-4o-mini", temperature=0)
2727

2828
BINARY_QUESTION_CHAIN = (
29-
binary_question_prompt
30-
| binary_question_model.with_structured_output(BinaryAnswer)
29+
binary_question_prompt | binary_question_model.with_structured_output(BinaryAnswer)
3130
)

python-langgraph/chains/escalation_check.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@ class EscalationCheck(BaseModel):
2828
escalation_check_model = ChatOpenAI(model="gpt-4o-mini", temperature=0)
2929

3030
ESCALATION_CHECK_CHAIN = (
31-
escalation_prompt
32-
| escalation_check_model.with_structured_output(EscalationCheck)
31+
escalation_prompt | escalation_check_model.with_structured_output(EscalationCheck)
3332
)

python-langgraph/chains/notice_extraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class NoticeEmailExtract(BaseModel):
3535
site_location: str | None = Field(
3636
default=None,
3737
description="""The site location of the project (if present
38-
in the message)""",
38+
in the message). Use the full address if possible.""",
3939
)
4040
violation_type: str | None = Field(
4141
default=None,

python-langgraph/example_emails.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
11
EMAILS = [
22
# Email 1
33
"""
4+
Date: October 15, 2024
5+
From: Occupational Safety and Health Administration (OSHA)
6+
To: Blue Ridge Construction, project 111232345 - Downtown Office Complex
7+
Location: Dallas, TX
8+
9+
During a recent inspection of your construction site at 123 Main Street,
10+
the following safety violations were identified:
11+
12+
Lack of fall protection: Workers on scaffolding above 10 feet were
13+
without required harnesses or other fall protection equipment.
14+
Unsafe scaffolding setup: Several scaffolding structures were noted as
15+
lacking secure base plates and bracing, creating potential collapse risks.
16+
Inadequate personal protective equipment (PPE): Multiple workers were found
17+
without proper PPE, including hard hats and safety glasses.
18+
Required Corrective Actions:
19+
20+
Install guardrails and fall arrest systems on all scaffolding over 10 feet.
21+
Conduct an inspection of all scaffolding structures and reinforce unstable
22+
sections. Ensure all workers on-site are provided with necessary PPE and conduct
23+
safety training on proper usage.
24+
Deadline for Compliance: All violations must be rectified by November 10, 2024.
25+
Failure to comply may result in fines of up to $25,000 per violation.
26+
27+
Contact: For questions or to confirm compliance, please reach out to the OSHA
28+
regional office at (555) 123-4567 or email [email protected].
29+
""",
30+
# Email 2
31+
"""
432
533
Hey Betsy,
634
Here's your invoice for $1000 for the cookies you ordered.
735
""",
8-
# Email 2
36+
# Email 3
937
"""
1038
1139
Hi Paul,
@@ -14,7 +42,7 @@
1442
Thanks,
1543
Terrance
1644
""",
17-
# Email 3
45+
# Email 4
1846
"""
1947
Date: January 10, 2025
2048
From: City of Los Angeles Building and Safety Department

python-langgraph/graphs/email_agent.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def forward_email(email_message: str, send_to_email: str) -> bool:
2626

2727

2828
@tool
29-
def send_wrong_email_notification_to_sender(
30-
sender_email: str, correct_department: str
31-
):
29+
def send_wrong_email_notification_to_sender(sender_email: str, correct_department: str):
3230
"""
3331
Send an email back to the sender informing them that
3432
they have the wrong address. The email should be sent
@@ -43,9 +41,7 @@ def send_wrong_email_notification_to_sender(
4341

4442

4543
@tool
46-
def extract_notice_data(
47-
email: str, escalation_criteria: str
48-
) -> NoticeEmailExtract:
44+
def extract_notice_data(email: str, escalation_criteria: str) -> NoticeEmailExtract:
4945
"""
5046
Extract structured fields from a regulatory notice.
5147
This should be used when the email message comes from
@@ -109,9 +105,7 @@ def determine_email_action(email: str) -> str:
109105
]
110106
tool_node = ToolNode(tools)
111107

112-
EMAIL_AGENT_MODEL = ChatOpenAI(model="gpt-4o-mini", temperature=0).bind_tools(
113-
tools
114-
)
108+
EMAIL_AGENT_MODEL = ChatOpenAI(model="gpt-4o-mini", temperature=0).bind_tools(tools)
115109

116110

117111
def call_agent_model_node(state: MessagesState) -> dict[str, list[AIMessage]]:

python-langgraph/graphs/notice_extraction.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,14 @@ def answer_follow_up_question_node(state: GraphState) -> GraphState:
8989
BINARY_QUESTION_CHAIN"""
9090

9191
if state["current_follow_up"]:
92-
9392
question = state["current_follow_up"] + " " + state["notice_message"]
9493

9594
answer = BINARY_QUESTION_CHAIN.invoke({"question": question})
9695

9796
if state.get("follow_ups"):
98-
9997
state["follow_ups"][state["current_follow_up"]] = answer
10098

10199
else:
102-
103100
state["follow_ups"] = {state["current_follow_up"]: answer}
104101

105102
return state
@@ -122,7 +119,6 @@ def route_follow_up_edge(state: GraphState) -> str:
122119
"""Determine whether a follow-up question is required"""
123120

124121
if state.get("current_follow_up"):
125-
126122
return "answer_follow_up_question"
127123

128124
return END

python-langgraph/utils/graph_utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,11 @@ def create_legal_ticket(
3232
]
3333

3434
if current_follow_ups:
35-
36-
follow_ups = [
37-
f for f in follow_ups if f not in current_follow_ups.keys()
38-
]
35+
follow_ups = [f for f in follow_ups if f not in current_follow_ups.keys()]
3936

4037
follow_up = random.choice(follow_ups)
4138

4239
if not follow_up:
43-
4440
LOGGER.info("Legal ticket created!")
4541
return follow_up
4642

0 commit comments

Comments
 (0)