Commit
·
18793f5
1
Parent(s):
058efce
update: streamlit version-still working on
Browse files- modules/nodes.py +27 -26
- modules/tools.py +1 -3
- paintrek-chat-v1.ipynb +0 -810
- paintrek-chat-v2.ipynb +27 -153
modules/nodes.py
CHANGED
@@ -15,32 +15,7 @@ intake_tools = [patient_id, symptom, pain, medical_hist, family_hist, social_his
|
|
15 |
# The LLM needs to know about all of the tools, so specify everything here.
|
16 |
llm_with_tools = llm.bind_tools(intake_tools)
|
17 |
|
18 |
-
|
19 |
-
"""Display the last model message to the user, and receive the user's input."""
|
20 |
-
last_msg = state["messages"][-1]
|
21 |
-
print("Model:", last_msg.content)
|
22 |
-
|
23 |
-
user_input = input("User: ")
|
24 |
-
|
25 |
-
# If it looks like the user is trying to quit, flag the conversation
|
26 |
-
# as over.
|
27 |
-
if user_input in {"q", "quit", "exit", "goodbye"}:
|
28 |
-
state["finished"] = True
|
29 |
-
|
30 |
-
return state | {"messages": [("user", user_input)]}
|
31 |
-
|
32 |
-
|
33 |
-
def maybe_exit_human_node(state: DataState) -> Literal["chatbot_healthassistant", "__end__"]:
|
34 |
-
"""Route to the chatbot, unless it looks like the user is exiting."""
|
35 |
-
if state.get("finished", False):
|
36 |
-
return END
|
37 |
-
else:
|
38 |
-
return "chatbot_healthassistant"
|
39 |
-
|
40 |
-
|
41 |
-
def chatbot_with_tools(state: DataState) -> DataState:
|
42 |
-
"""The chatbot with tools. A simple wrapper around the model's own chat interface."""
|
43 |
-
defaults = {"data": {"ID": {
|
44 |
"name": "",
|
45 |
"DOB": date(1900, 1, 1), # Default placeholder date
|
46 |
"gender": "",
|
@@ -106,6 +81,32 @@ def chatbot_with_tools(state: DataState) -> DataState:
|
|
106 |
}
|
107 |
}, "finished": False}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
if state["messages"]:
|
110 |
new_output = llm_with_tools.invoke([MEDICAL_INTAKE_SYSINT] + state["messages"])
|
111 |
else:
|
|
|
15 |
# The LLM needs to know about all of the tools, so specify everything here.
|
16 |
llm_with_tools = llm.bind_tools(intake_tools)
|
17 |
|
18 |
+
defaults = {"data": {"ID": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
"name": "",
|
20 |
"DOB": date(1900, 1, 1), # Default placeholder date
|
21 |
"gender": "",
|
|
|
81 |
}
|
82 |
}, "finished": False}
|
83 |
|
84 |
+
def human_node(state: DataState) -> DataState:
|
85 |
+
"""Display the last model message to the user, and receive the user's input."""
|
86 |
+
last_msg = state["messages"][-1]
|
87 |
+
print("Model:", last_msg.content)
|
88 |
+
|
89 |
+
user_input = input("User: ")
|
90 |
+
|
91 |
+
# If it looks like the user is trying to quit, flag the conversation
|
92 |
+
# as over.
|
93 |
+
if user_input in {"q", "quit", "exit", "goodbye"}:
|
94 |
+
state["finished"] = True
|
95 |
+
|
96 |
+
return state | {"messages": [("user", user_input)]}
|
97 |
+
|
98 |
+
|
99 |
+
def maybe_exit_human_node(state: DataState) -> Literal["chatbot_healthassistant", "__end__"]:
|
100 |
+
"""Route to the chatbot, unless it looks like the user is exiting."""
|
101 |
+
if state.get("finished", False):
|
102 |
+
return END
|
103 |
+
else:
|
104 |
+
return "chatbot_healthassistant"
|
105 |
+
|
106 |
+
|
107 |
+
def chatbot_with_tools(state: DataState) -> DataState:
|
108 |
+
"""The chatbot with tools. A simple wrapper around the model's own chat interface."""
|
109 |
+
|
110 |
if state["messages"]:
|
111 |
new_output = llm_with_tools.invoke([MEDICAL_INTAKE_SYSINT] + state["messages"])
|
112 |
else:
|
modules/tools.py
CHANGED
@@ -253,9 +253,7 @@ def data_node(state: DataState) -> DataState:
|
|
253 |
if not data:
|
254 |
print(" (no items)")
|
255 |
|
256 |
-
|
257 |
-
print(f" {data}")
|
258 |
-
|
259 |
response = input("Is this correct? ")
|
260 |
|
261 |
elif tool_call["name"] == "get_data":
|
|
|
253 |
if not data:
|
254 |
print(" (no items)")
|
255 |
|
256 |
+
print(state["data"])
|
|
|
|
|
257 |
response = input("Is this correct? ")
|
258 |
|
259 |
elif tool_call["name"] == "get_data":
|
paintrek-chat-v1.ipynb
DELETED
@@ -1,810 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 21,
|
6 |
-
"metadata": {
|
7 |
-
"execution": {
|
8 |
-
"iopub.execute_input": "2025-01-29T20:09:11.440091Z",
|
9 |
-
"iopub.status.busy": "2025-01-29T20:09:11.439766Z",
|
10 |
-
"iopub.status.idle": "2025-01-29T20:09:11.751153Z",
|
11 |
-
"shell.execute_reply": "2025-01-29T20:09:11.750263Z",
|
12 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.440060Z"
|
13 |
-
},
|
14 |
-
"id": "xaiioUQni_ga",
|
15 |
-
"trusted": true
|
16 |
-
},
|
17 |
-
"outputs": [],
|
18 |
-
"source": [
|
19 |
-
"import os\n",
|
20 |
-
"\n",
|
21 |
-
"from typing import Annotated, Dict, Any\n",
|
22 |
-
"from typing_extensions import TypedDict\n",
|
23 |
-
"from datetime import date\n",
|
24 |
-
"\n",
|
25 |
-
"from langgraph.graph.message import add_messages\n",
|
26 |
-
"from langgraph.graph import StateGraph, START, END\n",
|
27 |
-
"from langchain_google_genai import ChatGoogleGenerativeAI\n",
|
28 |
-
"from langchain_openai import ChatOpenAI\n",
|
29 |
-
"from langchain_ollama import ChatOllama\n",
|
30 |
-
"\n",
|
31 |
-
"from IPython.display import Image, display\n",
|
32 |
-
"from pprint import pprint\n",
|
33 |
-
"from langchain_core.messages.ai import AIMessage\n",
|
34 |
-
"from typing import Literal\n",
|
35 |
-
"from langchain_core.tools import tool\n",
|
36 |
-
"from langgraph.prebuilt import ToolNode"
|
37 |
-
]
|
38 |
-
},
|
39 |
-
{
|
40 |
-
"cell_type": "code",
|
41 |
-
"execution_count": 9,
|
42 |
-
"metadata": {
|
43 |
-
"execution": {
|
44 |
-
"iopub.execute_input": "2025-01-29T20:09:11.753044Z",
|
45 |
-
"iopub.status.busy": "2025-01-29T20:09:11.752582Z",
|
46 |
-
"iopub.status.idle": "2025-01-29T20:09:11.760099Z",
|
47 |
-
"shell.execute_reply": "2025-01-29T20:09:11.759040Z",
|
48 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.752997Z"
|
49 |
-
},
|
50 |
-
"id": "2RJQRlfVjqkJ",
|
51 |
-
"trusted": true
|
52 |
-
},
|
53 |
-
"outputs": [],
|
54 |
-
"source": [
|
55 |
-
"# setup_openai_api()\n",
|
56 |
-
"# llm = ChatOpenAI(temperature=0)\n",
|
57 |
-
"\n",
|
58 |
-
"# setup_ollama_api()\n",
|
59 |
-
"# llm = ChatOllama(model=\"llama3.2:latest\", temperature=0)\n",
|
60 |
-
"\n",
|
61 |
-
"\"\"\"llm = ChatOpenAI(\n",
|
62 |
-
" api_key=\"ollama\",\n",
|
63 |
-
" model=\"llama3.2:latest\",\n",
|
64 |
-
" base_url=\"http://141.211.127.171/\",\n",
|
65 |
-
")\"\"\"\n",
|
66 |
-
"\n",
|
67 |
-
"setup_google_api()\n",
|
68 |
-
"llm = ChatGoogleGenerativeAI(model=\"gemini-1.5-flash-latest\")\n"
|
69 |
-
]
|
70 |
-
},
|
71 |
-
{
|
72 |
-
"cell_type": "code",
|
73 |
-
"execution_count": 10,
|
74 |
-
"metadata": {},
|
75 |
-
"outputs": [
|
76 |
-
{
|
77 |
-
"data": {
|
78 |
-
"text/plain": [
|
79 |
-
"AIMessage(content='Hello there! How can I help you today?', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-eb83e576-ad78-40ef-86ef-4133db5ca191-0', usage_metadata={'input_tokens': 1, 'output_tokens': 11, 'total_tokens': 12, 'input_token_details': {'cache_read': 0}})"
|
80 |
-
]
|
81 |
-
},
|
82 |
-
"execution_count": 10,
|
83 |
-
"metadata": {},
|
84 |
-
"output_type": "execute_result"
|
85 |
-
}
|
86 |
-
],
|
87 |
-
"source": [
|
88 |
-
"llm.invoke(\"Hello\")"
|
89 |
-
]
|
90 |
-
},
|
91 |
-
{
|
92 |
-
"cell_type": "code",
|
93 |
-
"execution_count": 12,
|
94 |
-
"metadata": {
|
95 |
-
"execution": {
|
96 |
-
"iopub.execute_input": "2025-01-29T20:09:11.763927Z",
|
97 |
-
"iopub.status.busy": "2025-01-29T20:09:11.763466Z",
|
98 |
-
"iopub.status.idle": "2025-01-29T20:09:11.779944Z",
|
99 |
-
"shell.execute_reply": "2025-01-29T20:09:11.778675Z",
|
100 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.763894Z"
|
101 |
-
},
|
102 |
-
"id": "2RJQRlfVjqkJ",
|
103 |
-
"trusted": true
|
104 |
-
},
|
105 |
-
"outputs": [],
|
106 |
-
"source": [
|
107 |
-
"class PainLevels(TypedDict):\n",
|
108 |
-
" left_head: int\n",
|
109 |
-
" right_head: int\n",
|
110 |
-
" left_arm: int\n",
|
111 |
-
" left_hand: int\n",
|
112 |
-
" right_arm: int\n",
|
113 |
-
" right_hand: int\n",
|
114 |
-
" left_body_trunk: int\n",
|
115 |
-
" right_body_trunk: int\n",
|
116 |
-
" left_leg: int\n",
|
117 |
-
" left_foot: int\n",
|
118 |
-
" right_leg: int\n",
|
119 |
-
" right_foot: int\n",
|
120 |
-
"\n",
|
121 |
-
"class Surgery(TypedDict):\n",
|
122 |
-
" surgery_name: str\n",
|
123 |
-
" time: date\n",
|
124 |
-
"\n",
|
125 |
-
"class PatientID(TypedDict):\n",
|
126 |
-
" name: str\n",
|
127 |
-
" DOB: date\n",
|
128 |
-
" gender: str\n",
|
129 |
-
" contact: str\n",
|
130 |
-
" emergency_contact: str\n",
|
131 |
-
"\n",
|
132 |
-
"class MainSymptom(TypedDict):\n",
|
133 |
-
" main_symptom: str\n",
|
134 |
-
" length: str\n",
|
135 |
-
"\n",
|
136 |
-
"class Pain(TypedDict):\n",
|
137 |
-
" painlevel: PainLevels\n",
|
138 |
-
" pain_description: str\n",
|
139 |
-
" start_time: date\n",
|
140 |
-
" radiation: bool\n",
|
141 |
-
" triggers: str\n",
|
142 |
-
" symptom: str\n",
|
143 |
-
"\n",
|
144 |
-
"class MedicalHistory(TypedDict):\n",
|
145 |
-
" medical_condition: str\n",
|
146 |
-
" first_time: date\n",
|
147 |
-
" surgery_history: list[Surgery]\n",
|
148 |
-
" medication: str\n",
|
149 |
-
" allergy: str\n",
|
150 |
-
"\n",
|
151 |
-
"class FamilyHistory(TypedDict):\n",
|
152 |
-
" family_history: str\n",
|
153 |
-
"\n",
|
154 |
-
"class SocialHistory(TypedDict):\n",
|
155 |
-
" occupation: str\n",
|
156 |
-
" smoke: bool\n",
|
157 |
-
" alcohol: bool\n",
|
158 |
-
" drug: bool\n",
|
159 |
-
" support_system: str\n",
|
160 |
-
" living_condition: str\n",
|
161 |
-
"\n",
|
162 |
-
"class ReviewSystem(TypedDict):\n",
|
163 |
-
" weight_change: str\n",
|
164 |
-
" fever: bool\n",
|
165 |
-
" chill: bool\n",
|
166 |
-
" night_sweats: bool\n",
|
167 |
-
" sleep: str\n",
|
168 |
-
" gastrointestinal: str\n",
|
169 |
-
" urinary: str\n",
|
170 |
-
"\n",
|
171 |
-
"class PainManagement(TypedDict):\n",
|
172 |
-
" pain_medication: str\n",
|
173 |
-
" specialist: bool\n",
|
174 |
-
" other_therapy: str\n",
|
175 |
-
" effectiveness: bool\n",
|
176 |
-
"\n",
|
177 |
-
"class Functional(TypedDict):\n",
|
178 |
-
" life_quality: str\n",
|
179 |
-
" limit_activity: str\n",
|
180 |
-
" mood: str\n",
|
181 |
-
"\n",
|
182 |
-
"class Plan(TypedDict):\n",
|
183 |
-
" goal: str\n",
|
184 |
-
" expectation: str\n",
|
185 |
-
" alternative_treatment_illness: str\n",
|
186 |
-
"\n",
|
187 |
-
"class PatientData(TypedDict):\n",
|
188 |
-
" ID: PatientID\n",
|
189 |
-
" main: MainSymptom\n",
|
190 |
-
" \"\"\"pain: Pain\n",
|
191 |
-
" medical_hist: MedicalHistory\n",
|
192 |
-
" family_hist: FamilyHistory\n",
|
193 |
-
" social_hist: SocialHistory\n",
|
194 |
-
" review_system: ReviewSystem\n",
|
195 |
-
" pain_manage: PainManagement\n",
|
196 |
-
" functional: Functional\n",
|
197 |
-
" plan: Plan\"\"\"\n",
|
198 |
-
"\n",
|
199 |
-
"class DataState(TypedDict):\n",
|
200 |
-
" \"\"\"State representing the patient's data status and conversation.\"\"\"\n",
|
201 |
-
" messages: Annotated[list, add_messages]\n",
|
202 |
-
" data: Dict[str, PatientData]\n",
|
203 |
-
" finished: bool"
|
204 |
-
]
|
205 |
-
},
|
206 |
-
{
|
207 |
-
"cell_type": "code",
|
208 |
-
"execution_count": 13,
|
209 |
-
"metadata": {
|
210 |
-
"execution": {
|
211 |
-
"iopub.execute_input": "2025-01-29T20:09:11.781576Z",
|
212 |
-
"iopub.status.busy": "2025-01-29T20:09:11.781212Z",
|
213 |
-
"iopub.status.idle": "2025-01-29T20:09:11.800825Z",
|
214 |
-
"shell.execute_reply": "2025-01-29T20:09:11.799561Z",
|
215 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.781544Z"
|
216 |
-
},
|
217 |
-
"id": "2RJQRlfVjqkJ",
|
218 |
-
"trusted": true
|
219 |
-
},
|
220 |
-
"outputs": [],
|
221 |
-
"source": [
|
222 |
-
"# The system instruction defines how the chatbot is expected to behave and includes\n",
|
223 |
-
"# rules for when to call different functions, as well as rules for the conversation, such\n",
|
224 |
-
"# as tone and what is permitted for discussion.\n",
|
225 |
-
"MEDICAL_INTAKE_SYSINT = (\n",
|
226 |
-
" \"system\",\n",
|
227 |
-
" \"\"\"You are MedAssist, an intelligent medical intake system designed to gather comprehensive patient information. You guide patients through a structured data collection process while maintaining a supportive and professional demeanor.\n",
|
228 |
-
" \n",
|
229 |
-
" Before collecting any data, always use get_empty_datadict to create a new empty data dictionary for a new patient. Then use the following steps to collect data from a patient.\n",
|
230 |
-
" \n",
|
231 |
-
" Primary Data Collection Areas:\n",
|
232 |
-
" 1. Patient Identification\n",
|
233 |
-
" - Basic information (name, DOB, gender, contact)\n",
|
234 |
-
" - Emergency contact information\n",
|
235 |
-
"\n",
|
236 |
-
" 2. Main Symptom Assessment\n",
|
237 |
-
" - Primary complaint\n",
|
238 |
-
" - Duration of symptoms\n",
|
239 |
-
"\n",
|
240 |
-
" 3. Pain Assessment\n",
|
241 |
-
" - Pain location using body mapping (head, arms, hands, trunk, legs, feet)\n",
|
242 |
-
" - Pain intensity (0-10 scale for each location)\n",
|
243 |
-
" - Pain characteristics and patterns\n",
|
244 |
-
" - Onset time\n",
|
245 |
-
" - Radiation patterns\n",
|
246 |
-
" - Triggering factors\n",
|
247 |
-
" - Associated symptoms\n",
|
248 |
-
"\n",
|
249 |
-
" 4. Medical History\n",
|
250 |
-
" - Existing medical conditions\n",
|
251 |
-
" - First occurrence date\n",
|
252 |
-
" - Surgical history with dates\n",
|
253 |
-
" - Current medications\n",
|
254 |
-
" - Allergies\n",
|
255 |
-
"\n",
|
256 |
-
" 5. Background Information\n",
|
257 |
-
" - Family medical history\n",
|
258 |
-
" - Social history (occupation, lifestyle factors)\n",
|
259 |
-
" - Living conditions and support system\n",
|
260 |
-
"\n",
|
261 |
-
" 6. System Review\n",
|
262 |
-
" - Recent health changes\n",
|
263 |
-
" - Sleep patterns\n",
|
264 |
-
" - Gastrointestinal and urinary function\n",
|
265 |
-
" - Constitutional symptoms (fever, chills, night sweats)\n",
|
266 |
-
"\n",
|
267 |
-
" 7. Pain Management History\n",
|
268 |
-
" - Current pain medications\n",
|
269 |
-
" - Specialist consultations\n",
|
270 |
-
" - Alternative therapies\n",
|
271 |
-
" - Treatment effectiveness\n",
|
272 |
-
"\n",
|
273 |
-
" 8. Functional Assessment\n",
|
274 |
-
" - Impact on quality of life\n",
|
275 |
-
" - Activity limitations\n",
|
276 |
-
" - Mood and emotional state\n",
|
277 |
-
"\n",
|
278 |
-
" 9. Treatment Planning\n",
|
279 |
-
" - Treatment goals\n",
|
280 |
-
" - Patient expectations\n",
|
281 |
-
" - Alternative treatment considerations\n",
|
282 |
-
"\n",
|
283 |
-
" Data Management Commands:\n",
|
284 |
-
" - Use get_data to review current information\n",
|
285 |
-
" - Use add_to_data to append new information\n",
|
286 |
-
" - Use clear_data to reset the current session\n",
|
287 |
-
" - Use confirm_data to verify information with the patient\n",
|
288 |
-
" - Use insert_data to finalize the record\n",
|
289 |
-
"\n",
|
290 |
-
" Guidelines:\n",
|
291 |
-
" 1. Always introduce yourself and explain the intake process\n",
|
292 |
-
" 2. Collect information systematically but adapt to the patient's natural flow of conversation\n",
|
293 |
-
" 3. If patient starts with a specific concern, begin there but ensure all sections are eventually completed\n",
|
294 |
-
" 4. Use conversational prompts to gather missing information\n",
|
295 |
-
" 5. Validate pain levels on a 0-10 scale for each body location\n",
|
296 |
-
" 6. Regularly summarize collected information for patient verification\n",
|
297 |
-
" 7. Show empathy while maintaining professional boundaries\n",
|
298 |
-
" 8. Focus on medical data collection while acknowledging patient concerns\n",
|
299 |
-
" 9. Always confirm complete data set before finalizing\n",
|
300 |
-
" 10. Thank the patient and provide clear closure when finished\n",
|
301 |
-
"\n",
|
302 |
-
" Remember:\n",
|
303 |
-
" - Maintain medical privacy and confidentiality\n",
|
304 |
-
" - Stay within scope of data collection\n",
|
305 |
-
" - Be patient and clear in communication\n",
|
306 |
-
" - Double-check all information before final submission\n",
|
307 |
-
" - Adapt language to patient's comprehension level\n",
|
308 |
-
" - Document 'unknown' or 'not applicable' when appropriate\n",
|
309 |
-
"\n",
|
310 |
-
" Always confirm_data with the patient before calling save_data, and address any corrections needed. Once save_data is complete, provide a summary and conclude the session.\"\"\"\n",
|
311 |
-
")\n",
|
312 |
-
"\n",
|
313 |
-
"# This is the message with which the system opens the conversation.\n",
|
314 |
-
"WELCOME_MSG = \"Welcome to the Paintrek world. I am a health assistant, an interactive clinical recording system. I will ask you questions about your pain and related symptoms and record your responses. I will then store this information securely. At any time, you can type `q` to quit.\""
|
315 |
-
]
|
316 |
-
},
|
317 |
-
{
|
318 |
-
"cell_type": "code",
|
319 |
-
"execution_count": 14,
|
320 |
-
"metadata": {
|
321 |
-
"execution": {
|
322 |
-
"iopub.execute_input": "2025-01-29T20:09:11.828125Z",
|
323 |
-
"iopub.status.busy": "2025-01-29T20:09:11.827744Z",
|
324 |
-
"iopub.status.idle": "2025-01-29T20:09:11.835672Z",
|
325 |
-
"shell.execute_reply": "2025-01-29T20:09:11.834403Z",
|
326 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.828093Z"
|
327 |
-
},
|
328 |
-
"id": "SWXwd1ITUSPF",
|
329 |
-
"trusted": true
|
330 |
-
},
|
331 |
-
"outputs": [],
|
332 |
-
"source": [
|
333 |
-
"def human_node(state: DataState) -> DataState:\n",
|
334 |
-
" \"\"\"Display the last model message to the user, and receive the user's input.\"\"\"\n",
|
335 |
-
" last_msg = state[\"messages\"][-1]\n",
|
336 |
-
" print(\"Model:\", last_msg.content)\n",
|
337 |
-
"\n",
|
338 |
-
" user_input = input(\"User: \")\n",
|
339 |
-
"\n",
|
340 |
-
" # If it looks like the user is trying to quit, flag the conversation\n",
|
341 |
-
" # as over.\n",
|
342 |
-
" if user_input in {\"q\", \"quit\", \"exit\", \"goodbye\"}:\n",
|
343 |
-
" state[\"finished\"] = True\n",
|
344 |
-
"\n",
|
345 |
-
" return state | {\"messages\": [(\"user\", user_input)]}\n",
|
346 |
-
"\n",
|
347 |
-
"\n",
|
348 |
-
"def maybe_exit_human_node(state: DataState) -> Literal[\"chatbot_healthassistant\", \"__end__\"]:\n",
|
349 |
-
" \"\"\"Route to the chatbot, unless it looks like the user is exiting.\"\"\"\n",
|
350 |
-
" if state.get(\"finished\", False):\n",
|
351 |
-
" return END\n",
|
352 |
-
" else:\n",
|
353 |
-
" return \"chatbot_healthassistant\"\n",
|
354 |
-
" \n"
|
355 |
-
]
|
356 |
-
},
|
357 |
-
{
|
358 |
-
"cell_type": "code",
|
359 |
-
"execution_count": 15,
|
360 |
-
"metadata": {},
|
361 |
-
"outputs": [],
|
362 |
-
"source": [
|
363 |
-
"@tool\n",
|
364 |
-
"def get_empty_datadict(state: DataState) -> DataState:\n",
|
365 |
-
" \"\"\"Before collecting data, get a empty data dictionary for a new patient\"\"\"\n",
|
366 |
-
" # Note that this is just hard-coded text, but you could connect this to a live stock\n",
|
367 |
-
" # database, or you could use Gemini's multi-modal capabilities and take live photos of\n",
|
368 |
-
" # your cafe's chalk menu or the products on the counter and assmble them into an input.\n",
|
369 |
-
" state[\"data\"]= {\n",
|
370 |
-
" \"patient_1\": {\n",
|
371 |
-
" \"data_1\": { # Placeholder patient ID, can be replaced dynamically\n",
|
372 |
-
" \"ID\": {\n",
|
373 |
-
" \"name\": \"\",\n",
|
374 |
-
" \"DOB\": date(1900, 1, 1), # Default placeholder date\n",
|
375 |
-
" \"gender\": \"\",\n",
|
376 |
-
" \"contact\": \"\",\n",
|
377 |
-
" \"emergency_contact\": \"\"\n",
|
378 |
-
" },\n",
|
379 |
-
" \"main\": {\n",
|
380 |
-
" \"main_symptom\": \"\",\n",
|
381 |
-
" \"length\": \"\"\n",
|
382 |
-
" }\n",
|
383 |
-
" }\n",
|
384 |
-
" }\n",
|
385 |
-
" }\n",
|
386 |
-
" return state\n"
|
387 |
-
]
|
388 |
-
},
|
389 |
-
{
|
390 |
-
"cell_type": "code",
|
391 |
-
"execution_count": 16,
|
392 |
-
"metadata": {
|
393 |
-
"execution": {
|
394 |
-
"iopub.execute_input": "2025-01-29T20:09:11.858218Z",
|
395 |
-
"iopub.status.busy": "2025-01-29T20:09:11.857696Z",
|
396 |
-
"iopub.status.idle": "2025-01-29T20:09:11.903753Z",
|
397 |
-
"shell.execute_reply": "2025-01-29T20:09:11.902647Z",
|
398 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.858152Z"
|
399 |
-
},
|
400 |
-
"id": "jqsLovPBQe0I",
|
401 |
-
"trusted": true
|
402 |
-
},
|
403 |
-
"outputs": [],
|
404 |
-
"source": [
|
405 |
-
"from collections.abc import Iterable\n",
|
406 |
-
"from random import randint\n",
|
407 |
-
"\n",
|
408 |
-
"from langgraph.prebuilt import InjectedState\n",
|
409 |
-
"from langchain_core.messages.tool import ToolMessage\n",
|
410 |
-
"\n",
|
411 |
-
"# These functions have no body; LangGraph does not allow @tools to update\n",
|
412 |
-
"# the conversation state, so you will implement a separate node to handle\n",
|
413 |
-
"# state updates. Using @tools is still very convenient for defining the tool\n",
|
414 |
-
"# schema, so empty functions have been defined that will be bound to the LLM\n",
|
415 |
-
"# but their implementation is deferred to the order_node.\n",
|
416 |
-
"\n",
|
417 |
-
"\n",
|
418 |
-
"@tool\n",
|
419 |
-
"def patient_id(name: str, DOB: str, gender: str, contact: str, emergency_contact: str) -> str:\n",
|
420 |
-
" \"\"\"Collecting basic patient identification information including:\n",
|
421 |
-
" - Basic information (name, DOB, gender, contact details)\n",
|
422 |
-
" - Emergency contact information\n",
|
423 |
-
"\n",
|
424 |
-
" Returns:\n",
|
425 |
-
" The updated data with the patient ID information added.\n",
|
426 |
-
" \"\"\"\n",
|
427 |
-
"\n",
|
428 |
-
"@tool\n",
|
429 |
-
"def symptom(main_symptom: str, length: str) -> str:\n",
|
430 |
-
" \"\"\"Collecting patient's main symptom assessment including:\n",
|
431 |
-
" - Primary symptoms\n",
|
432 |
-
" - Duration of the symptoms\n",
|
433 |
-
"\n",
|
434 |
-
" Returns:\n",
|
435 |
-
" The updated data with the patient's symptom information added.\n",
|
436 |
-
" \"\"\"\n",
|
437 |
-
"\n",
|
438 |
-
"\n",
|
439 |
-
"@tool\n",
|
440 |
-
"def confirm_data() -> str:\n",
|
441 |
-
" \"\"\"Asks the patient if the data intake is correct.\n",
|
442 |
-
"\n",
|
443 |
-
" Returns:\n",
|
444 |
-
" The user's free-text response.\n",
|
445 |
-
" \"\"\"\n",
|
446 |
-
"\n",
|
447 |
-
"\n",
|
448 |
-
"@tool\n",
|
449 |
-
"def get_data() -> str:\n",
|
450 |
-
" \"\"\"Returns the users data so far. One item per line.\"\"\"\n",
|
451 |
-
"\n",
|
452 |
-
"\n",
|
453 |
-
"@tool\n",
|
454 |
-
"def clear_data():\n",
|
455 |
-
" \"\"\"Removes all items from the user's order.\"\"\"\n",
|
456 |
-
"\n",
|
457 |
-
"\n",
|
458 |
-
"@tool\n",
|
459 |
-
"def save_data() -> int:\n",
|
460 |
-
" \"\"\"Send the data into database.\n",
|
461 |
-
"\n",
|
462 |
-
" Returns:\n",
|
463 |
-
" The status of data saving, finished.\n",
|
464 |
-
" \"\"\"\n",
|
465 |
-
"\n",
|
466 |
-
"\n",
|
467 |
-
"def data_node(state: DataState) -> DataState:\n",
|
468 |
-
" \"\"\"The ordering node. This is where the dataintake is manipulated.\"\"\"\n",
|
469 |
-
" tool_msg = state.get(\"messages\", [])[-1]\n",
|
470 |
-
" data = state.get(\"data\", [])\n",
|
471 |
-
" outbound_msgs = []\n",
|
472 |
-
" data_saved = False\n",
|
473 |
-
"\n",
|
474 |
-
" for tool_call in tool_msg.tool_calls:\n",
|
475 |
-
"\n",
|
476 |
-
" if tool_call[\"name\"] == \"patient_id\":\n",
|
477 |
-
"\n",
|
478 |
-
" # Each order item is just a string. This is where it assembled as \"drink (modifiers, ...)\".\n",
|
479 |
-
" patient_name = tool_call[\"args\"][\"name\"]\n",
|
480 |
-
" patient_DOB = tool_call[\"args\"][\"DOB\"]\n",
|
481 |
-
" patient_gender = tool_call[\"args\"][\"gender\"]\n",
|
482 |
-
" patient_contact = tool_call[\"args\"][\"contact\"]\n",
|
483 |
-
" patient_emergency_contact = tool_call[\"args\"][\"emergency_contact\"]\n",
|
484 |
-
"\n",
|
485 |
-
" data[\"ID\"][\"name\"]=patient_name\n",
|
486 |
-
" data[\"ID\"][\"DOB\"]=patient_DOB\n",
|
487 |
-
" data[\"ID\"][\"gender\"]=patient_gender\n",
|
488 |
-
" data[\"ID\"][\"contact\"]=patient_contact\n",
|
489 |
-
" data[\"ID\"][\"emergency_contact\"]=patient_emergency_contact\n",
|
490 |
-
" \n",
|
491 |
-
" response = \"\\n\".join(data)\n",
|
492 |
-
"\n",
|
493 |
-
" if tool_call[\"name\"] == \"symptom\":\n",
|
494 |
-
"\n",
|
495 |
-
" # Each order item is just a string. This is where it assembled as \"drink (modifiers, ...)\".\n",
|
496 |
-
" main_symptom = tool_call[\"args\"][\"main_symptom\"]\n",
|
497 |
-
" symptom_length = tool_call[\"args\"][\"length\"]\n",
|
498 |
-
"\n",
|
499 |
-
" data[\"symptom\"][\"main_symptom\"]=main_symptom\n",
|
500 |
-
" data[\"symptom\"][\"symptom_length\"]=symptom_length\n",
|
501 |
-
" response = \"\\n\".join(data)\n",
|
502 |
-
"\n",
|
503 |
-
" elif tool_call[\"name\"] == \"confirm_data\":\n",
|
504 |
-
"\n",
|
505 |
-
" # We could entrust the LLM to do order confirmation, but it is a good practice to\n",
|
506 |
-
" # show the user the exact data that comprises their order so that what they confirm\n",
|
507 |
-
" # precisely matches the order that goes to the kitchen - avoiding hallucination\n",
|
508 |
-
" # or reality skew.\n",
|
509 |
-
"\n",
|
510 |
-
" # In a real scenario, this is where you would connect your POS screen to show the\n",
|
511 |
-
" # order to the user.\n",
|
512 |
-
"\n",
|
513 |
-
" print(\"Your input data:\")\n",
|
514 |
-
" if not data:\n",
|
515 |
-
" print(\" (no items)\")\n",
|
516 |
-
"\n",
|
517 |
-
" for data in data:\n",
|
518 |
-
" print(f\" {data}\")\n",
|
519 |
-
"\n",
|
520 |
-
" response = input(\"Is this correct? \")\n",
|
521 |
-
"\n",
|
522 |
-
" elif tool_call[\"name\"] == \"get_data\":\n",
|
523 |
-
"\n",
|
524 |
-
" response = \"\\n\".join(data) if data else \"(no data)\"\n",
|
525 |
-
"\n",
|
526 |
-
" elif tool_call[\"name\"] == \"clear_data\":\n",
|
527 |
-
"\n",
|
528 |
-
" data.clear()\n",
|
529 |
-
" response = None\n",
|
530 |
-
"\n",
|
531 |
-
" elif tool_call[\"name\"] == \"save_data\":\n",
|
532 |
-
"\n",
|
533 |
-
" #order_text = \"\\n\".join(order)\n",
|
534 |
-
" print(\"Saving the data!\")\n",
|
535 |
-
" #print(order_text)\n",
|
536 |
-
"\n",
|
537 |
-
" # TODO(you!): Implement cafe.\n",
|
538 |
-
" data_saved = True\n",
|
539 |
-
" # response = randint(1, 5) # ETA in minutes\n",
|
540 |
-
"\n",
|
541 |
-
" else:\n",
|
542 |
-
" raise NotImplementedError(f'Unknown tool call: {tool_call[\"name\"]}')\n",
|
543 |
-
"\n",
|
544 |
-
" # Record the tool results as tool messages.\n",
|
545 |
-
" outbound_msgs.append(\n",
|
546 |
-
" ToolMessage(\n",
|
547 |
-
" content=response,\n",
|
548 |
-
" name=tool_call[\"name\"],\n",
|
549 |
-
" tool_call_id=tool_call[\"id\"],\n",
|
550 |
-
" )\n",
|
551 |
-
" )\n",
|
552 |
-
"\n",
|
553 |
-
" return {\"messages\": outbound_msgs, \"data\": data, \"finished\": data_saved}\n",
|
554 |
-
"\n",
|
555 |
-
"def chatbot_with_tools(state: DataState) -> DataState:\n",
|
556 |
-
" \"\"\"The chatbot with tools. A simple wrapper around the model's own chat interface.\"\"\"\n",
|
557 |
-
" defaults = {\"data\": {\n",
|
558 |
-
" \"patient_1\": {\n",
|
559 |
-
" \"data_1\": { # Placeholder patient ID, can be replaced dynamically\n",
|
560 |
-
" \"ID\": {\n",
|
561 |
-
" \"name\": \"\",\n",
|
562 |
-
" \"DOB\": date(1900, 1, 1), # Default placeholder date\n",
|
563 |
-
" \"gender\": \"\",\n",
|
564 |
-
" \"contact\": \"\",\n",
|
565 |
-
" \"emergency_contact\": \"\"\n",
|
566 |
-
" },\n",
|
567 |
-
" \"main\": {\n",
|
568 |
-
" \"main_symptom\": \"\",\n",
|
569 |
-
" \"length\": \"\"\n",
|
570 |
-
" }\n",
|
571 |
-
" }\n",
|
572 |
-
" }\n",
|
573 |
-
" }, \"finished\": False}\n",
|
574 |
-
"\n",
|
575 |
-
" if state[\"messages\"]:\n",
|
576 |
-
" new_output = llm_with_tools.invoke([MEDICAL_INTAKE_SYSINT] + state[\"messages\"])\n",
|
577 |
-
" else:\n",
|
578 |
-
" new_output = AIMessage(content=WELCOME_MSG)\n",
|
579 |
-
"\n",
|
580 |
-
" # Set up some defaults if not already set, then pass through the provided state,\n",
|
581 |
-
" # overriding only the \"messages\" field.\n",
|
582 |
-
" return defaults | state | {\"messages\": [new_output]}\n",
|
583 |
-
"\n",
|
584 |
-
"\n",
|
585 |
-
"def maybe_route_to_tools(state: DataState) -> str:\n",
|
586 |
-
" \"\"\"Route between chat and tool nodes if a tool call is made.\"\"\"\n",
|
587 |
-
" if not (msgs := state.get(\"messages\", [])):\n",
|
588 |
-
" raise ValueError(f\"No messages found when parsing state: {state}\")\n",
|
589 |
-
"\n",
|
590 |
-
" msg = msgs[-1]\n",
|
591 |
-
"\n",
|
592 |
-
" if state.get(\"finished\", False):\n",
|
593 |
-
" # When an order is placed, exit the app. The system instruction indicates\n",
|
594 |
-
" # that the chatbot should say thanks and goodbye at this point, so we can exit\n",
|
595 |
-
" # cleanly.\n",
|
596 |
-
" return END\n",
|
597 |
-
"\n",
|
598 |
-
" elif hasattr(msg, \"tool_calls\") and len(msg.tool_calls) > 0:\n",
|
599 |
-
" # Route to `tools` node for any automated tool calls first.\n",
|
600 |
-
" if any(\n",
|
601 |
-
" tool[\"name\"] for tool in msg.tool_calls\n",
|
602 |
-
" ):\n",
|
603 |
-
" return \"datacreation\"\n",
|
604 |
-
" else:\n",
|
605 |
-
" return \"documenting\"\n",
|
606 |
-
"\n",
|
607 |
-
" else:\n",
|
608 |
-
" return \"patient\""
|
609 |
-
]
|
610 |
-
},
|
611 |
-
{
|
612 |
-
"cell_type": "code",
|
613 |
-
"execution_count": 17,
|
614 |
-
"metadata": {
|
615 |
-
"execution": {
|
616 |
-
"iopub.execute_input": "2025-01-29T20:09:11.906458Z",
|
617 |
-
"iopub.status.busy": "2025-01-29T20:09:11.905241Z",
|
618 |
-
"iopub.status.idle": "2025-01-29T20:09:11.994921Z",
|
619 |
-
"shell.execute_reply": "2025-01-29T20:09:11.993761Z",
|
620 |
-
"shell.execute_reply.started": "2025-01-29T20:09:11.906419Z"
|
621 |
-
},
|
622 |
-
"id": "9rqkQzlZxrzp",
|
623 |
-
"trusted": true
|
624 |
-
},
|
625 |
-
"outputs": [
|
626 |
-
{
|
627 |
-
"data": {
|
628 |
-
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAd0AAAFNCAIAAADKOSJ6AAAAAXNSR0IArs4c6QAAIABJREFUeJzs3WdYE9nbBvATEkLovSNiV1AEARUbKqKCXbFj77r2LtjLWlnXFbFgwa6IWLGCFRQVEQUUqUovCQmE9GTeD7Mvf1bpJJkQnt/lBwmTmTvt4eTMmXNIGIYhAAAACkOF6AAAAAD+A+oyAAAoFqjLAACgWKAuAwCAYoG6DAAAigXqMgAAKBYK0QEAMfIzuBy2mFMqFoswPk9CdJw6odJU1NRVNLTJmroUIws1ouMAICskGL/cfGAY9u1dWXpCeUZCectOGipkkoYOWd+EKuA2jbqsQkbMIiGnTEzTUMlN57XqrNm6i2aL9hpE5wJAyqAuNxefnjNjIxgtbTVbd9Zs1VmTRCIRnahRykqEGQnlRTl8ep6g13BDq3ZQnYHygLqs/HLTOQ/OFrR30uo9wkiF3LTL8e8KfvCi79G1DSiDJpsSnQUA6YC6rOQ+v2amxbOHTDfT0Fbmcwk5ady7J3OnrLPWMVQlOgsAjQV1WZl9fVda+JPv5m1MdBB5EPIll/f/nLCyhboWmegsADQK1GWlFX23mMeVDJxgQnQQubqw+4fXLDNDGK0BmjIYv6ycvseWlTFFza0oI4Sm+ba8ciCL6BQANArUZSVUnMvPSCwfMs2M6CDEmLrR+uG5PKJTANBwUJeV0OtbxbY9dYhOQRh9E6q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wzuJ43jJKTwRvot0sTAUfWAjBsfhFgRrFM5zKSXdkEoA0aB+RgggKUvxBp6jZPhWkrfZVheGhfuKgDwA7kMAmCxsGdeTvjxQn+4CwmtgavDuU8R8gRuuAsBwA/kMggsJp5T+DtFX+tQuAsJFc01bUa+YOY8GMEAjAO5DEaVNBNf8ow0InvNmvahWTn8rMfE4S4EgABgPgZ4CJ2GrNnZr5wlI+Ij4ckL24jTpDHmqogZOZHw54CIBLkMHs7r8Z7cO6TTUIrUGKFsos7zddoobachOtpb+LxCFg9jyoC5IJfBWGn7yPoTem0/JZThIgWOS7isKKaPg3k9XoeVtAzZ7QY7IefMLRBPSw/+I+YABBfkMvh5zAbXrVZbR5PNrKdoysPhs0VyntM6Hku+jV00znYYScrhpl0eeSJvWjo+fY5QpuSM4VAAwg9yGfxCXq+XcnrsZrfD5vZ6wl2NPwxDXD4LJ9h8ASwRByYeyGUAAGAWpo8PAgDAZAO5DAAAzAK5DAAAzAK5DAAAzAK5DAAAzAK5DAAAzPI/w2mQbbF6IGEAAAAASUVORK5CYII=",
|
629 |
-
"text/plain": [
|
630 |
-
"<IPython.core.display.Image object>"
|
631 |
-
]
|
632 |
-
},
|
633 |
-
"execution_count": 17,
|
634 |
-
"metadata": {},
|
635 |
-
"output_type": "execute_result"
|
636 |
-
}
|
637 |
-
],
|
638 |
-
"source": [
|
639 |
-
"# Auto-tools will be invoked automatically by the ToolNode\n",
|
640 |
-
"auto_tools = [get_empty_datadict]\n",
|
641 |
-
"tool_node = ToolNode(auto_tools)\n",
|
642 |
-
"\n",
|
643 |
-
"# Order-tools will be handled by the order node.\n",
|
644 |
-
"intake_tools = [patient_id, symptom, confirm_data, get_data, clear_data, save_data]\n",
|
645 |
-
"\n",
|
646 |
-
"# The LLM needs to know about all of the tools, so specify everything here.\n",
|
647 |
-
"llm_with_tools = llm.bind_tools(auto_tools + intake_tools)\n",
|
648 |
-
"\n",
|
649 |
-
"\n",
|
650 |
-
"graph_builder = StateGraph(DataState)\n",
|
651 |
-
"\n",
|
652 |
-
"# Nodes\n",
|
653 |
-
"graph_builder.add_node(\"chatbot_healthassistant\", chatbot_with_tools)\n",
|
654 |
-
"graph_builder.add_node(\"patient\", human_node)\n",
|
655 |
-
"graph_builder.add_node(\"datacreation\", tool_node)\n",
|
656 |
-
"graph_builder.add_node(\"documenting\", data_node)\n",
|
657 |
-
"\n",
|
658 |
-
"# Chatbot -> {ordering, tools, human, END}\n",
|
659 |
-
"graph_builder.add_conditional_edges(\"chatbot_healthassistant\", maybe_route_to_tools)\n",
|
660 |
-
"# Human -> {chatbot, END}\n",
|
661 |
-
"graph_builder.add_conditional_edges(\"patient\", maybe_exit_human_node)\n",
|
662 |
-
"# TestCase_Paintrek\n",
|
663 |
-
"# Tools (both kinds) always route back to chat afterwards.\n",
|
664 |
-
"graph_builder.add_edge(\"datacreation\", \"chatbot_healthassistant\")\n",
|
665 |
-
"graph_builder.add_edge(\"documenting\", \"chatbot_healthassistant\")\n",
|
666 |
-
"\n",
|
667 |
-
"graph_builder.add_edge(START, \"chatbot_healthassistant\")\n",
|
668 |
-
"graph_with_order_tools = graph_builder.compile()\n",
|
669 |
-
"\n",
|
670 |
-
"Image(graph_with_order_tools.get_graph().draw_mermaid_png())"
|
671 |
-
]
|
672 |
-
},
|
673 |
-
{
|
674 |
-
"cell_type": "markdown",
|
675 |
-
"metadata": {
|
676 |
-
"id": "G0SVsDu4gD_T"
|
677 |
-
},
|
678 |
-
"source": [
|
679 |
-
"Now run the complete ordering system graph.\n",
|
680 |
-
"\n",
|
681 |
-
"**You must uncomment the `.invoke(...)` line to run this step.**"
|
682 |
-
]
|
683 |
-
},
|
684 |
-
{
|
685 |
-
"cell_type": "code",
|
686 |
-
"execution_count": 20,
|
687 |
-
"metadata": {
|
688 |
-
"execution": {
|
689 |
-
"iopub.execute_input": "2025-01-29T20:09:38.185616Z",
|
690 |
-
"iopub.status.busy": "2025-01-29T20:09:38.185131Z",
|
691 |
-
"iopub.status.idle": "2025-01-29T20:10:08.474591Z",
|
692 |
-
"shell.execute_reply": "2025-01-29T20:10:08.472926Z",
|
693 |
-
"shell.execute_reply.started": "2025-01-29T20:09:38.185577Z"
|
694 |
-
},
|
695 |
-
"id": "NCRSgaBUfIHF",
|
696 |
-
"trusted": true
|
697 |
-
},
|
698 |
-
"outputs": [
|
699 |
-
{
|
700 |
-
"name": "stdout",
|
701 |
-
"output_type": "stream",
|
702 |
-
"text": [
|
703 |
-
"Model: Welcome to the Paintrek world. I am a health assistant, an interactive clinical recording system. I will ask you questions about your pain and related symptoms and record your responses. I will then store this information securely. At any time, you can type `q` to quit.\n"
|
704 |
-
]
|
705 |
-
},
|
706 |
-
{
|
707 |
-
"ename": "KeyboardInterrupt",
|
708 |
-
"evalue": "Interrupted by user",
|
709 |
-
"output_type": "error",
|
710 |
-
"traceback": [
|
711 |
-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
712 |
-
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
713 |
-
"Cell \u001b[0;32mIn[20], line 6\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# The default recursion limit for traversing nodes is 25 - setting it higher\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m# means you can try a more complex order with multiple steps and round-trips.\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# config = {\"recursion_limit\": 500}\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Uncomment this line to execute the graph:\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m state \u001b[38;5;241m=\u001b[39m graph_with_order_tools\u001b[38;5;241m.\u001b[39minvoke({\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmessages\u001b[39m\u001b[38;5;124m\"\u001b[39m: []})\n",
|
714 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/langgraph/pregel/__init__.py:1961\u001b[0m, in \u001b[0;36mPregel.invoke\u001b[0;34m(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug, **kwargs)\u001b[0m\n\u001b[1;32m 1959\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 1960\u001b[0m chunks \u001b[38;5;241m=\u001b[39m []\n\u001b[0;32m-> 1961\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m chunk \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstream(\n\u001b[1;32m 1962\u001b[0m \u001b[38;5;28minput\u001b[39m,\n\u001b[1;32m 1963\u001b[0m config,\n\u001b[1;32m 1964\u001b[0m stream_mode\u001b[38;5;241m=\u001b[39mstream_mode,\n\u001b[1;32m 1965\u001b[0m output_keys\u001b[38;5;241m=\u001b[39moutput_keys,\n\u001b[1;32m 1966\u001b[0m interrupt_before\u001b[38;5;241m=\u001b[39minterrupt_before,\n\u001b[1;32m 1967\u001b[0m interrupt_after\u001b[38;5;241m=\u001b[39minterrupt_after,\n\u001b[1;32m 1968\u001b[0m debug\u001b[38;5;241m=\u001b[39mdebug,\n\u001b[1;32m 1969\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[1;32m 1970\u001b[0m ):\n\u001b[1;32m 1971\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m stream_mode \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalues\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 1972\u001b[0m latest \u001b[38;5;241m=\u001b[39m chunk\n",
|
715 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/langgraph/pregel/__init__.py:1670\u001b[0m, in \u001b[0;36mPregel.stream\u001b[0;34m(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug, subgraphs)\u001b[0m\n\u001b[1;32m 1664\u001b[0m \u001b[38;5;66;03m# Similarly to Bulk Synchronous Parallel / Pregel model\u001b[39;00m\n\u001b[1;32m 1665\u001b[0m \u001b[38;5;66;03m# computation proceeds in steps, while there are channel updates.\u001b[39;00m\n\u001b[1;32m 1666\u001b[0m \u001b[38;5;66;03m# Channel updates from step N are only visible in step N+1\u001b[39;00m\n\u001b[1;32m 1667\u001b[0m \u001b[38;5;66;03m# channels are guaranteed to be immutable for the duration of the step,\u001b[39;00m\n\u001b[1;32m 1668\u001b[0m \u001b[38;5;66;03m# with channel updates applied only at the transition between steps.\u001b[39;00m\n\u001b[1;32m 1669\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m loop\u001b[38;5;241m.\u001b[39mtick(input_keys\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minput_channels):\n\u001b[0;32m-> 1670\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m _ \u001b[38;5;129;01min\u001b[39;00m runner\u001b[38;5;241m.\u001b[39mtick(\n\u001b[1;32m 1671\u001b[0m loop\u001b[38;5;241m.\u001b[39mtasks\u001b[38;5;241m.\u001b[39mvalues(),\n\u001b[1;32m 1672\u001b[0m timeout\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstep_timeout,\n\u001b[1;32m 1673\u001b[0m retry_policy\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mretry_policy,\n\u001b[1;32m 1674\u001b[0m get_waiter\u001b[38;5;241m=\u001b[39mget_waiter,\n\u001b[1;32m 1675\u001b[0m ):\n\u001b[1;32m 1676\u001b[0m \u001b[38;5;66;03m# emit output\u001b[39;00m\n\u001b[1;32m 1677\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m output()\n\u001b[1;32m 1678\u001b[0m \u001b[38;5;66;03m# emit output\u001b[39;00m\n",
|
716 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/langgraph/pregel/runner.py:230\u001b[0m, in \u001b[0;36mPregelRunner.tick\u001b[0;34m(self, tasks, reraise, timeout, retry_policy, get_waiter)\u001b[0m\n\u001b[1;32m 228\u001b[0m t \u001b[38;5;241m=\u001b[39m tasks[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 229\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 230\u001b[0m run_with_retry(\n\u001b[1;32m 231\u001b[0m t,\n\u001b[1;32m 232\u001b[0m retry_policy,\n\u001b[1;32m 233\u001b[0m configurable\u001b[38;5;241m=\u001b[39m{\n\u001b[1;32m 234\u001b[0m CONFIG_KEY_SEND: partial(writer, t),\n\u001b[1;32m 235\u001b[0m CONFIG_KEY_CALL: partial(call, t),\n\u001b[1;32m 236\u001b[0m },\n\u001b[1;32m 237\u001b[0m )\n\u001b[1;32m 238\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcommit(t, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m 239\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
|
717 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/langgraph/pregel/retry.py:40\u001b[0m, in \u001b[0;36mrun_with_retry\u001b[0;34m(task, retry_policy, configurable)\u001b[0m\n\u001b[1;32m 38\u001b[0m task\u001b[38;5;241m.\u001b[39mwrites\u001b[38;5;241m.\u001b[39mclear()\n\u001b[1;32m 39\u001b[0m \u001b[38;5;66;03m# run the task\u001b[39;00m\n\u001b[0;32m---> 40\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m task\u001b[38;5;241m.\u001b[39mproc\u001b[38;5;241m.\u001b[39minvoke(task\u001b[38;5;241m.\u001b[39minput, config)\n\u001b[1;32m 41\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ParentCommand \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 42\u001b[0m ns: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m config[CONF][CONFIG_KEY_CHECKPOINT_NS]\n",
|
718 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/langgraph/utils/runnable.py:462\u001b[0m, in \u001b[0;36mRunnableSeq.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 458\u001b[0m config \u001b[38;5;241m=\u001b[39m patch_config(\n\u001b[1;32m 459\u001b[0m config, callbacks\u001b[38;5;241m=\u001b[39mrun_manager\u001b[38;5;241m.\u001b[39mget_child(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mseq:step:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mi\u001b[38;5;250m \u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;241m1\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 460\u001b[0m )\n\u001b[1;32m 461\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m i \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[0;32m--> 462\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m step\u001b[38;5;241m.\u001b[39minvoke(\u001b[38;5;28minput\u001b[39m, config, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 463\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 464\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m step\u001b[38;5;241m.\u001b[39minvoke(\u001b[38;5;28minput\u001b[39m, config)\n",
|
719 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/langgraph/utils/runnable.py:226\u001b[0m, in \u001b[0;36mRunnableCallable.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 224\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 225\u001b[0m context\u001b[38;5;241m.\u001b[39mrun(_set_config_context, config)\n\u001b[0;32m--> 226\u001b[0m ret \u001b[38;5;241m=\u001b[39m context\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfunc, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 227\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(ret, Runnable) \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrecurse:\n\u001b[1;32m 228\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ret\u001b[38;5;241m.\u001b[39minvoke(\u001b[38;5;28minput\u001b[39m, config)\n",
|
720 |
-
"Cell \u001b[0;32mIn[14], line 6\u001b[0m, in \u001b[0;36mhuman_node\u001b[0;34m(state)\u001b[0m\n\u001b[1;32m 3\u001b[0m last_msg \u001b[38;5;241m=\u001b[39m state[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmessages\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mModel:\u001b[39m\u001b[38;5;124m\"\u001b[39m, last_msg\u001b[38;5;241m.\u001b[39mcontent)\n\u001b[0;32m----> 6\u001b[0m user_input \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUser: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 8\u001b[0m \u001b[38;5;66;03m# If it looks like the user is trying to quit, flag the conversation\u001b[39;00m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;66;03m# as over.\u001b[39;00m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m user_input \u001b[38;5;129;01min\u001b[39;00m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mq\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mquit\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexit\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgoodbye\u001b[39m\u001b[38;5;124m\"\u001b[39m}:\n",
|
721 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/ipykernel/kernelbase.py:1282\u001b[0m, in \u001b[0;36mKernel.raw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 1280\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mraw_input was called, but this frontend does not support input requests.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1281\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m StdinNotImplementedError(msg)\n\u001b[0;32m-> 1282\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_input_request(\n\u001b[1;32m 1283\u001b[0m \u001b[38;5;28mstr\u001b[39m(prompt),\n\u001b[1;32m 1284\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parent_ident[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshell\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 1285\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_parent(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshell\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[1;32m 1286\u001b[0m password\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 1287\u001b[0m )\n",
|
722 |
-
"File \u001b[0;32m~/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/ipykernel/kernelbase.py:1325\u001b[0m, in \u001b[0;36mKernel._input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 1322\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m:\n\u001b[1;32m 1323\u001b[0m \u001b[38;5;66;03m# re-raise KeyboardInterrupt, to truncate traceback\u001b[39;00m\n\u001b[1;32m 1324\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInterrupted by user\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m-> 1325\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m(msg) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1326\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[1;32m 1327\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlog\u001b[38;5;241m.\u001b[39mwarning(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid Message:\u001b[39m\u001b[38;5;124m\"\u001b[39m, exc_info\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
|
723 |
-
"\u001b[0;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
|
724 |
-
]
|
725 |
-
}
|
726 |
-
],
|
727 |
-
"source": [
|
728 |
-
"# The default recursion limit for traversing nodes is 25 - setting it higher\n",
|
729 |
-
"# means you can try a more complex order with multiple steps and round-trips.\n",
|
730 |
-
"# config = {\"recursion_limit\": 500}\n",
|
731 |
-
"\n",
|
732 |
-
"# Uncomment this line to execute the graph:\n",
|
733 |
-
"state = graph_with_order_tools.invoke({\"messages\": []})\n",
|
734 |
-
"\n",
|
735 |
-
"# pprint(state)"
|
736 |
-
]
|
737 |
-
},
|
738 |
-
{
|
739 |
-
"cell_type": "code",
|
740 |
-
"execution_count": 23,
|
741 |
-
"metadata": {
|
742 |
-
"execution": {
|
743 |
-
"iopub.execute_input": "2024-11-26T20:49:57.557546Z",
|
744 |
-
"iopub.status.busy": "2024-11-26T20:49:57.557070Z",
|
745 |
-
"iopub.status.idle": "2024-11-26T20:49:57.565305Z",
|
746 |
-
"shell.execute_reply": "2024-11-26T20:49:57.563903Z",
|
747 |
-
"shell.execute_reply.started": "2024-11-26T20:49:57.557497Z"
|
748 |
-
},
|
749 |
-
"id": "n4jUJCr3fJpy",
|
750 |
-
"trusted": true
|
751 |
-
},
|
752 |
-
"outputs": [
|
753 |
-
{
|
754 |
-
"name": "stdout",
|
755 |
-
"output_type": "stream",
|
756 |
-
"text": [
|
757 |
-
"dict_keys(['messages', 'finished'])\n"
|
758 |
-
]
|
759 |
-
}
|
760 |
-
],
|
761 |
-
"source": [
|
762 |
-
"# Uncomment this once you have run the graph from the previous cell.\n",
|
763 |
-
"pprint(state.keys())"
|
764 |
-
]
|
765 |
-
},
|
766 |
-
{
|
767 |
-
"cell_type": "code",
|
768 |
-
"execution_count": null,
|
769 |
-
"metadata": {
|
770 |
-
"trusted": true
|
771 |
-
},
|
772 |
-
"outputs": [],
|
773 |
-
"source": []
|
774 |
-
}
|
775 |
-
],
|
776 |
-
"metadata": {
|
777 |
-
"colab": {
|
778 |
-
"name": "day-3-building-an-agent-with-langgraph.ipynb",
|
779 |
-
"toc_visible": true
|
780 |
-
},
|
781 |
-
"kaggle": {
|
782 |
-
"accelerator": "none",
|
783 |
-
"dataSources": [],
|
784 |
-
"dockerImageVersionId": 30786,
|
785 |
-
"isGpuEnabled": false,
|
786 |
-
"isInternetEnabled": true,
|
787 |
-
"language": "python",
|
788 |
-
"sourceType": "notebook"
|
789 |
-
},
|
790 |
-
"kernelspec": {
|
791 |
-
"display_name": "paintrekbot",
|
792 |
-
"language": "python",
|
793 |
-
"name": "python3"
|
794 |
-
},
|
795 |
-
"language_info": {
|
796 |
-
"codemirror_mode": {
|
797 |
-
"name": "ipython",
|
798 |
-
"version": 3
|
799 |
-
},
|
800 |
-
"file_extension": ".py",
|
801 |
-
"mimetype": "text/x-python",
|
802 |
-
"name": "python",
|
803 |
-
"nbconvert_exporter": "python",
|
804 |
-
"pygments_lexer": "ipython3",
|
805 |
-
"version": "3.12.8"
|
806 |
-
}
|
807 |
-
},
|
808 |
-
"nbformat": 4,
|
809 |
-
"nbformat_minor": 4
|
810 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paintrek-chat-v2.ipynb
CHANGED
@@ -103,121 +103,37 @@
|
|
103 |
"text": [
|
104 |
"Executing the chatbot graph...\n",
|
105 |
"Model: Welcome to the Paintrek world. I am a health assistant, an interactive clinical recording system. I will ask you questions about your pain and related symptoms and record your responses. I will then store this information securely. At any time, you can type `q` to quit.\n",
|
106 |
-
"Model: First, I need to collect some basic information for identification.
|
107 |
"Model: Thank you. Now, can you describe your main symptom and how long you've been experiencing it?\n",
|
108 |
-
"Model:
|
109 |
-
"Model:
|
110 |
-
"Model: Now, let's
|
111 |
-
"Model:
|
112 |
-
"Model:
|
113 |
-
"Model:
|
114 |
-
"Model:
|
115 |
-
"Model:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
"Saving the data!\n",
|
117 |
-
"
|
118 |
]
|
119 |
-
},
|
120 |
-
{
|
121 |
-
"data": {
|
122 |
-
"text/plain": [
|
123 |
-
"{'messages': [AIMessage(content='Welcome to the Paintrek world. I am a health assistant, an interactive clinical recording system. I will ask you questions about your pain and related symptoms and record your responses. I will then store this information securely. At any time, you can type `q` to quit.', additional_kwargs={}, response_metadata={}, id='9d9f4dc0-206c-474f-8322-458b7aeec747'),\n",
|
124 |
-
" HumanMessage(content=\"Let's start\", additional_kwargs={}, response_metadata={}, id='c5cbbc6e-1cd8-4924-84ad-19636037a42b'),\n",
|
125 |
-
" AIMessage(content='First, I need to collect some basic information for identification. Could you please provide your full name, date of birth, gender, and contact number? Also, please provide the name and contact information for an emergency contact.', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-625a1eff-7e43-46a9-b824-0ca7de7959a5-0', usage_metadata={'input_tokens': 1526, 'output_tokens': 47, 'total_tokens': 1573, 'input_token_details': {'cache_read': 0}}),\n",
|
126 |
-
" HumanMessage(content='I am Frank, DOB 1986-01-01, male, phone number is 12345, emergency name is Zoe, number is 67890.', additional_kwargs={}, response_metadata={}, id='efaee7ea-596d-4152-8872-5eb8633f76a5'),\n",
|
127 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'patient_id', 'arguments': '{\"contact\": \"12345\", \"DOB\": \"1986-01-01\", \"gender\": \"male\", \"emergency_contact\": \"Zoe, 67890\", \"name\": \"Frank\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-3c5557d4-313e-482e-8901-d7ecd490a9f0-0', tool_calls=[{'name': 'patient_id', 'args': {'contact': '12345', 'DOB': '1986-01-01', 'gender': 'male', 'emergency_contact': 'Zoe, 67890', 'name': 'Frank'}, 'id': 'bb2eb4b7-ff42-4584-aa0b-f6bca017bd51', 'type': 'tool_call'}], usage_metadata={'input_tokens': 1615, 'output_tokens': 35, 'total_tokens': 1650, 'input_token_details': {'cache_read': 0}}),\n",
|
128 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='patient_id', id='25805edd-4bea-4d24-864f-e23cb87306cf', tool_call_id='bb2eb4b7-ff42-4584-aa0b-f6bca017bd51'),\n",
|
129 |
-
" AIMessage(content=\"Thank you. Now, can you describe your main symptom and how long you've been experiencing it?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-f7885dbe-c5e7-48c3-9e85-e111c07625dc-0', usage_metadata={'input_tokens': 1684, 'output_tokens': 22, 'total_tokens': 1706, 'input_token_details': {'cache_read': 0}}),\n",
|
130 |
-
" HumanMessage(content='I had a headache, and it started two days ago.', additional_kwargs={}, response_metadata={}, id='aa33a92d-255f-483a-93e1-ef552dc5b109'),\n",
|
131 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'symptom', 'arguments': '{\"symptom_length\": \"2 days\", \"main_symptom\": \"Headache\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-e2451cbe-be34-4d38-b8d4-5fd8797ee910-0', tool_calls=[{'name': 'symptom', 'args': {'symptom_length': '2 days', 'main_symptom': 'Headache'}, 'id': 'bfdd9836-6f09-4d36-8308-c5571241e899', 'type': 'tool_call'}], usage_metadata={'input_tokens': 1717, 'output_tokens': 14, 'total_tokens': 1731, 'input_token_details': {'cache_read': 0}}),\n",
|
132 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='symptom', id='ed5418d4-6e70-46fd-ad59-3eb26e72d84d', tool_call_id='bfdd9836-6f09-4d36-8308-c5571241e899'),\n",
|
133 |
-
" AIMessage(content='Could you tell me more about the headache? Where is the pain located? Is it on the left, right, or both sides? On a scale of 0 to 10, with 0 being no pain and 10 being the worst pain imaginable, how intense is the pain? What are the characteristics of the pain (e.g., sharp, dull, throbbing)? When did it start? Does the pain radiate to any other areas? What, if anything, triggers the headache? Are there any other symptoms associated with the headache (e.g., nausea, vomiting, visual disturbances)?', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-2fe7272d-2b5a-4fa0-81e2-837f3fcd95d0-0', usage_metadata={'input_tokens': 1764, 'output_tokens': 125, 'total_tokens': 1889, 'input_token_details': {'cache_read': 0}}),\n",
|
134 |
-
" HumanMessage(content='My pain is located on the right head, and the scale is 2, the pain is sharp, the pain started 2 days ago, and the pain is not radiating. Cold will trigger the pain, and no other symptoms. ', additional_kwargs={}, response_metadata={}, id='2e0970d1-76f8-46e1-b9e5-f6c6da1f2a65'),\n",
|
135 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'pain', 'arguments': '{\"pain_location\": \"Right head\", \"radiation\": false, \"start_time\": \"2 days ago\", \"symptom\": \"No other symptoms\", \"pain_side\": \"Right\", \"pain_intensity\": 2.0, \"pain_description\": \"Sharp\", \"triggers\": \"Cold\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-ccea4875-140d-4d67-8257-972f59fef2d6-0', tool_calls=[{'name': 'pain', 'args': {'pain_location': 'Right head', 'radiation': False, 'start_time': '2 days ago', 'symptom': 'No other symptoms', 'pain_side': 'Right', 'pain_intensity': 2.0, 'pain_description': 'Sharp', 'triggers': 'Cold'}, 'id': 'c00f1773-566e-4caa-b920-6316efd45ef6', 'type': 'tool_call'}], usage_metadata={'input_tokens': 1936, 'output_tokens': 31, 'total_tokens': 1967, 'input_token_details': {'cache_read': 0}}),\n",
|
136 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='pain', id='1f2dbda4-bcad-41a6-b415-d034211f2836', tool_call_id='c00f1773-566e-4caa-b920-6316efd45ef6'),\n",
|
137 |
-
" AIMessage(content=\"Let's move on to your medical history. Do you have any existing medical conditions? When were they first diagnosed? Have you ever had any surgeries? If so, when? Are you currently taking any medications? Do you have any allergies?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-1584fcb0-bea9-47b1-88ec-7a2acacd22e0-0', usage_metadata={'input_tokens': 1999, 'output_tokens': 52, 'total_tokens': 2051, 'input_token_details': {'cache_read': 0}}),\n",
|
138 |
-
" HumanMessage(content='I had sinus, diagnosed in 2001-01-01, I did not have any surgery. I am taking ibprofin, no allergies.', additional_kwargs={}, response_metadata={}, id='f59997a9-b21b-4506-9a76-bd11f8d45570'),\n",
|
139 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'medical_hist', 'arguments': '{\"medical_condition\": \"Sinus\", \"first_time\": \"2001-01-01\", \"allergy\": \"None\", \"surgery_history\": \"None\", \"medication\": \"Ibprofin\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-b577e889-c382-4b92-bb64-436a179d42f3-0', tool_calls=[{'name': 'medical_hist', 'args': {'medical_condition': 'Sinus', 'first_time': '2001-01-01', 'allergy': 'None', 'surgery_history': 'None', 'medication': 'Ibprofin'}, 'id': '909c6e8c-1f8b-4dfa-8419-444ef8e1c3ba', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2085, 'output_tokens': 32, 'total_tokens': 2117, 'input_token_details': {'cache_read': 0}}),\n",
|
140 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='medical_hist', id='d3a4d6fe-c438-491d-9491-ba863db704db', tool_call_id='909c6e8c-1f8b-4dfa-8419-444ef8e1c3ba'),\n",
|
141 |
-
" AIMessage(content=\"Now, let's discuss your family medical history. Are there any significant medical conditions that run in your family?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-a39755e6-5a91-4af1-8519-bf5505f87420-0', usage_metadata={'input_tokens': 2151, 'output_tokens': 24, 'total_tokens': 2175, 'input_token_details': {'cache_read': 0}}),\n",
|
142 |
-
" HumanMessage(content='My mom had a lung cancer at 45.', additional_kwargs={}, response_metadata={}, id='5e7229d4-75c1-4af0-86ee-0bf6b0cf79b8'),\n",
|
143 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'family_hist', 'arguments': '{\"family_history\": \"Mother had lung cancer at 45\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-649911e3-2e04-411f-9748-6118b678c995-0', tool_calls=[{'name': 'family_hist', 'args': {'family_history': 'Mother had lung cancer at 45'}, 'id': '00538952-3a24-43af-bd00-d8be94a23c0d', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2185, 'output_tokens': 14, 'total_tokens': 2199, 'input_token_details': {'cache_read': 0}}),\n",
|
144 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='family_hist', id='185e4a86-c4f7-467c-9cc4-694e90f14fd5', tool_call_id='00538952-3a24-43af-bd00-d8be94a23c0d'),\n",
|
145 |
-
" AIMessage(content='To get a more complete picture, could you share some information about your lifestyle? What is your occupation? Do you smoke, drink alcohol, or use drugs? Could you describe your living situation and support system?', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-b7feb925-e20f-4f26-8e6a-d6d0b6d6f535-0', usage_metadata={'input_tokens': 2233, 'output_tokens': 44, 'total_tokens': 2277, 'input_token_details': {'cache_read': 0}}),\n",
|
146 |
-
" HumanMessage(content=\"I am a data scientist, I am a viggie. I don't use tobbaco or alcohol. My stress level is midium. \", additional_kwargs={}, response_metadata={}, id='9729418d-ccaf-499e-b113-102bda1ffb44'),\n",
|
147 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'social_hist', 'arguments': '{\"occupation\": \"Data scientist\", \"alcohol\": false, \"support_system\": \"Unknown\", \"living_condition\": \"Unknown\", \"smoke\": false, \"drug\": false}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-4cd83ff3-1c6c-4a25-b6ce-324f643a9983-0', tool_calls=[{'name': 'social_hist', 'args': {'occupation': 'Data scientist', 'alcohol': False, 'support_system': 'Unknown', 'living_condition': 'Unknown', 'smoke': False, 'drug': False}, 'id': '9e7e59cd-1f82-4509-90fa-0f04e2ae3247', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2307, 'output_tokens': 17, 'total_tokens': 2324, 'input_token_details': {'cache_read': 0}}),\n",
|
148 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='social_hist', id='b5fb4fb9-7a92-4e9b-ae60-f712789d0763', tool_call_id='9e7e59cd-1f82-4509-90fa-0f04e2ae3247'),\n",
|
149 |
-
" AIMessage(content=\"We're almost done. Let's do a quick system review. Have you experienced any recent weight changes? Have you had any fever, chills, or night sweats? How is your sleep? How are your gastrointestinal and urinary functions?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-ad5ad812-ff0f-4df5-8b24-ff8477b846ea-0', usage_metadata={'input_tokens': 2358, 'output_tokens': 53, 'total_tokens': 2411, 'input_token_details': {'cache_read': 0}}),\n",
|
150 |
-
" HumanMessage(content='I sleep well, and no other symptoms.', additional_kwargs={}, response_metadata={}, id='fdae21fe-3b98-4481-8b84-9a37278dbe2e'),\n",
|
151 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'review_system', 'arguments': '{\"night_sweats\": false, \"urinary\": \"Normal\", \"fever\": false, \"chill\": false, \"weight_change\": \"None\", \"gastrointestinal\": \"Normal\", \"sleep\": \"Well\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-5fee7657-9fa1-49e7-8eae-6692fb4c091f-0', tool_calls=[{'name': 'review_system', 'args': {'night_sweats': False, 'urinary': 'Normal', 'fever': False, 'chill': False, 'weight_change': 'None', 'gastrointestinal': 'Normal', 'sleep': 'Well'}, 'id': '8eb97099-d605-4f5f-b68f-09b42c1b57a3', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2419, 'output_tokens': 22, 'total_tokens': 2441, 'input_token_details': {'cache_read': 0}}),\n",
|
152 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='review_system', id='79d367c4-9f55-4bf4-8e57-61a181f04c50', tool_call_id='8eb97099-d605-4f5f-b68f-09b42c1b57a3'),\n",
|
153 |
-
" AIMessage(content=\"Finally, let's talk about your pain management. What pain medications are you currently using? Have you consulted any specialists for your pain? Have you tried any alternative therapies? How effective has your pain management been so far?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-b04ae18f-4886-4f4e-bac0-249fa25a9104-0', usage_metadata={'input_tokens': 2475, 'output_tokens': 46, 'total_tokens': 2521, 'input_token_details': {'cache_read': 0}}),\n",
|
154 |
-
" HumanMessage(content=\"No, I am not taking any other medication, and I haven't tried any alternative therapies. \", additional_kwargs={}, response_metadata={}, id='2f7663f0-bf45-4a88-8166-87296401b484'),\n",
|
155 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'pain_manage', 'arguments': '{\"other_therapy\": \"No\", \"effectiveness\": \"Unknown\", \"specialist\": false, \"pain_medication\": \"No\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-957a0591-60ca-432f-8d58-96b6e320d3f8-0', tool_calls=[{'name': 'pain_manage', 'args': {'other_therapy': 'No', 'effectiveness': 'Unknown', 'specialist': False, 'pain_medication': 'No'}, 'id': '8e3b6362-259c-4761-8afd-8dafdf089d64', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2541, 'output_tokens': 14, 'total_tokens': 2555, 'input_token_details': {'cache_read': 0}}),\n",
|
156 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='pain_manage', id='05176215-7b75-44b0-bf4b-781415e99c92', tool_call_id='8e3b6362-259c-4761-8afd-8dafdf089d64'),\n",
|
157 |
-
" AIMessage(content=\"To conclude, could you please describe how this headache impacts your quality of life, any limitations on your activities, and your current mood? Also, what are your treatment goals and expectations? Are there any alternative treatments you'd consider?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-180eb319-b8ab-4839-9e4a-0dfddc1db7a5-0', usage_metadata={'input_tokens': 2589, 'output_tokens': 49, 'total_tokens': 2638, 'input_token_details': {'cache_read': 0}}),\n",
|
158 |
-
" HumanMessage(content='I am okay on my mood, and my quality of life is also good. I want to fix my headache.', additional_kwargs={}, response_metadata={}, id='8d9d0595-b4c8-4363-8a12-9d25d622df40'),\n",
|
159 |
-
" AIMessage(content='', additional_kwargs={'function_call': {'name': 'plan', 'arguments': '{\"alternative_treatment\": \"None\", \"goal\": \"Fix headache\", \"expectation\": \"Fix headache\"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-b8aa1b09-e8ca-4b28-975b-b9c236fec8cf-0', tool_calls=[{'name': 'functional', 'args': {'limit_activity': 'None', 'life_quality': 'Good', 'mood': 'Okay'}, 'id': 'a4e3932e-f8f4-4f04-b197-f8a121bc9a83', 'type': 'tool_call'}, {'name': 'plan', 'args': {'alternative_treatment': 'None', 'goal': 'Fix headache', 'expectation': 'Fix headache'}, 'id': '6b547d21-4aa1-4446-bd88-513e89f40a00', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2660, 'output_tokens': 23, 'total_tokens': 2683, 'input_token_details': {'cache_read': 0}}),\n",
|
160 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='functional', id='ac6a0abc-75f5-4166-be1d-0b0380b4be42', tool_call_id='a4e3932e-f8f4-4f04-b197-f8a121bc9a83'),\n",
|
161 |
-
" ToolMessage(content='ID\\nsymptom\\npain\\nmedical_hist\\nfamily_hist\\nsocial_hist\\nreview_system\\npain_manage\\nfunctional\\nplan', name='plan', id='36e5190d-6e92-408e-81cc-a4e4002db458', tool_call_id='6b547d21-4aa1-4446-bd88-513e89f40a00'),\n",
|
162 |
-
" AIMessage(content=\"Before we finalize this record, could you please confirm that all the information we've gathered is accurate?\", additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-418aedcc-36df-4162-88fa-502fe88c92de-0', usage_metadata={'input_tokens': 2746, 'output_tokens': 22, 'total_tokens': 2768, 'input_token_details': {'cache_read': 0}}),\n",
|
163 |
-
" HumanMessage(content='I am okay on my mood, and my quality of life is also good. I want to fix my headache.', additional_kwargs={}, response_metadata={}, id='284f6024-d70b-4465-a9cf-359d9302bc55'),\n",
|
164 |
-
" AIMessage(content='Okay, I will save your information now.', additional_kwargs={'function_call': {'name': 'save_data', 'arguments': '{}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-50382a72-be29-45cb-b883-fa7242e1c717-0', tool_calls=[{'name': 'save_data', 'args': {}, 'id': '4da5513e-f8e6-4b08-a9ff-70e63825b9df', 'type': 'tool_call'}], usage_metadata={'input_tokens': 2790, 'output_tokens': 13, 'total_tokens': 2803, 'input_token_details': {'cache_read': 0}}),\n",
|
165 |
-
" ToolMessage(content='4', name='save_data', id='b332e4a1-52dc-4739-9abc-1d8ff8d973d2', tool_call_id='4da5513e-f8e6-4b08-a9ff-70e63825b9df'),\n",
|
166 |
-
" AIMessage(content='Thank you for providing all the necessary information. Your medical record has been successfully saved. Please let me know if you have any further questions or need additional assistance. Have a good day.', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': []}, id='run-63007311-b94d-49c4-8ed1-0c23a32af250-0', usage_metadata={'input_tokens': 2797, 'output_tokens': 40, 'total_tokens': 2837, 'input_token_details': {'cache_read': 0}})],\n",
|
167 |
-
" 'data': {'ID': {'name': 'Frank',\n",
|
168 |
-
" 'DOB': '1986-01-01',\n",
|
169 |
-
" 'gender': 'male',\n",
|
170 |
-
" 'contact': '12345',\n",
|
171 |
-
" 'emergency_contact': 'Zoe, 67890'},\n",
|
172 |
-
" 'symptom': {'main_symptom': 'Headache', 'symptom_length': '2 days'},\n",
|
173 |
-
" 'pain': {'pain_location': 'Right head',\n",
|
174 |
-
" 'pain_side': 'Right',\n",
|
175 |
-
" 'pain_intensity': 2.0,\n",
|
176 |
-
" 'pain_description': 'Sharp',\n",
|
177 |
-
" 'start_time': '2 days ago',\n",
|
178 |
-
" 'radiation': False,\n",
|
179 |
-
" 'triggers': 'Cold',\n",
|
180 |
-
" 'symptom': 'No other symptoms'},\n",
|
181 |
-
" 'medical_hist': {'medical_condition': 'Sinus',\n",
|
182 |
-
" 'first_time': '2001-01-01',\n",
|
183 |
-
" 'surgery_history': 'None',\n",
|
184 |
-
" 'medication': 'Ibprofin',\n",
|
185 |
-
" 'allergy': 'None'},\n",
|
186 |
-
" 'family_hist': {'family_history': 'Mother had lung cancer at 45'},\n",
|
187 |
-
" 'social_hist': {'occupation': 'Data scientist',\n",
|
188 |
-
" 'smoke': False,\n",
|
189 |
-
" 'alcohol': False,\n",
|
190 |
-
" 'drug': False,\n",
|
191 |
-
" 'support_system': 'Unknown',\n",
|
192 |
-
" 'living_condition': 'Unknown'},\n",
|
193 |
-
" 'review_system': {'weight_change': 'None',\n",
|
194 |
-
" 'fever': False,\n",
|
195 |
-
" 'chill': False,\n",
|
196 |
-
" 'night_sweats': False,\n",
|
197 |
-
" 'sleep': 'Well',\n",
|
198 |
-
" 'gastrointestinal': 'Normal',\n",
|
199 |
-
" 'urinary': 'Normal'},\n",
|
200 |
-
" 'pain_manage': {'pain_medication': 'No',\n",
|
201 |
-
" 'specialist': False,\n",
|
202 |
-
" 'other_therapy': 'No',\n",
|
203 |
-
" 'effectiveness': 'Unknown'},\n",
|
204 |
-
" 'functional': {'life_quality': 'Good',\n",
|
205 |
-
" 'limit_activity': 'None',\n",
|
206 |
-
" 'mood': 'Okay'},\n",
|
207 |
-
" 'plan': {'goal': 'Fix headache',\n",
|
208 |
-
" 'expectation': 'Fix headache',\n",
|
209 |
-
" 'alternative_treatment': 'None'}},\n",
|
210 |
-
" 'finished': True}"
|
211 |
-
]
|
212 |
-
},
|
213 |
-
"metadata": {},
|
214 |
-
"output_type": "display_data"
|
215 |
}
|
216 |
],
|
217 |
"source": [
|
218 |
"# The default recursion limit for traversing nodes is 25 - setting it higher\n",
|
219 |
"# means you can try a more complex order with multiple steps and round-trips.\n",
|
220 |
-
"config = {\"recursion_limit\":
|
221 |
"\n",
|
222 |
"# Uncomment this line to execute the graph:\n",
|
223 |
"# Clear output before running new states\n",
|
@@ -226,15 +142,15 @@
|
|
226 |
"# Ensure messages print immediately\n",
|
227 |
"print(\"Executing the chatbot graph...\", flush=True)\n",
|
228 |
"state = graph_with_order_tools.invoke({\"messages\": []}, config)\n",
|
229 |
-
"display(state) # Ensures state is shown in Jupyter\n",
|
230 |
-
"sys.stdout.flush()\n",
|
231 |
"\n",
|
232 |
"# pprint(state)"
|
233 |
]
|
234 |
},
|
235 |
{
|
236 |
"cell_type": "code",
|
237 |
-
"execution_count":
|
238 |
"metadata": {
|
239 |
"trusted": true
|
240 |
},
|
@@ -242,49 +158,7 @@
|
|
242 |
{
|
243 |
"data": {
|
244 |
"text/plain": [
|
245 |
-
"
|
246 |
-
" 'DOB': '1986-01-01',\n",
|
247 |
-
" 'gender': 'male',\n",
|
248 |
-
" 'contact': '12345',\n",
|
249 |
-
" 'emergency_contact': 'Zoe, 67890'},\n",
|
250 |
-
" 'symptom': {'main_symptom': 'Headache', 'symptom_length': '2 days'},\n",
|
251 |
-
" 'pain': {'pain_location': 'Right head',\n",
|
252 |
-
" 'pain_side': 'Right',\n",
|
253 |
-
" 'pain_intensity': 2.0,\n",
|
254 |
-
" 'pain_description': 'Sharp',\n",
|
255 |
-
" 'start_time': '2 days ago',\n",
|
256 |
-
" 'radiation': False,\n",
|
257 |
-
" 'triggers': 'Cold',\n",
|
258 |
-
" 'symptom': 'No other symptoms'},\n",
|
259 |
-
" 'medical_hist': {'medical_condition': 'Sinus',\n",
|
260 |
-
" 'first_time': '2001-01-01',\n",
|
261 |
-
" 'surgery_history': 'None',\n",
|
262 |
-
" 'medication': 'Ibprofin',\n",
|
263 |
-
" 'allergy': 'None'},\n",
|
264 |
-
" 'family_hist': {'family_history': 'Mother had lung cancer at 45'},\n",
|
265 |
-
" 'social_hist': {'occupation': 'Data scientist',\n",
|
266 |
-
" 'smoke': False,\n",
|
267 |
-
" 'alcohol': False,\n",
|
268 |
-
" 'drug': False,\n",
|
269 |
-
" 'support_system': 'Unknown',\n",
|
270 |
-
" 'living_condition': 'Unknown'},\n",
|
271 |
-
" 'review_system': {'weight_change': 'None',\n",
|
272 |
-
" 'fever': False,\n",
|
273 |
-
" 'chill': False,\n",
|
274 |
-
" 'night_sweats': False,\n",
|
275 |
-
" 'sleep': 'Well',\n",
|
276 |
-
" 'gastrointestinal': 'Normal',\n",
|
277 |
-
" 'urinary': 'Normal'},\n",
|
278 |
-
" 'pain_manage': {'pain_medication': 'No',\n",
|
279 |
-
" 'specialist': False,\n",
|
280 |
-
" 'other_therapy': 'No',\n",
|
281 |
-
" 'effectiveness': 'Unknown'},\n",
|
282 |
-
" 'functional': {'life_quality': 'Good',\n",
|
283 |
-
" 'limit_activity': 'None',\n",
|
284 |
-
" 'mood': 'Okay'},\n",
|
285 |
-
" 'plan': {'goal': 'Fix headache',\n",
|
286 |
-
" 'expectation': 'Fix headache',\n",
|
287 |
-
" 'alternative_treatment': 'None'}}"
|
288 |
]
|
289 |
},
|
290 |
"execution_count": 4,
|
|
|
103 |
"text": [
|
104 |
"Executing the chatbot graph...\n",
|
105 |
"Model: Welcome to the Paintrek world. I am a health assistant, an interactive clinical recording system. I will ask you questions about your pain and related symptoms and record your responses. I will then store this information securely. At any time, you can type `q` to quit.\n",
|
106 |
+
"Model: First, I need to collect some basic information for identification. What is your full name, date of birth (YYYY-MM-DD), gender, and contact number?\n",
|
107 |
"Model: Thank you. Now, can you describe your main symptom and how long you've been experiencing it?\n",
|
108 |
+
"Model: Okay. Let's assess the headache. Where is the pain located? Which side? And on a scale of 0 to 10 (0 being no pain, 10 being the worst pain imaginable), what is the intensity?\n",
|
109 |
+
"Model: To continue, could you provide information on your medical history, including any existing medical conditions, surgeries, medications, and allergies? Please include dates where applicable.\n",
|
110 |
+
"Model: Thank you. Now, let's move on to your family medical history. Are there any significant medical conditions that run in your family?\n",
|
111 |
+
"Model: Could you tell me a bit about your social history, including your occupation, living situation, and whether you smoke, drink alcohol, or use drugs? Also, please describe your support system.\n",
|
112 |
+
"Model: Let's do a quick systems review. Have you experienced any recent weight changes, fever, chills, night sweats, changes in sleep patterns, or any gastrointestinal or urinary issues?\n",
|
113 |
+
"Model: Regarding pain management, what pain medications are you currently using, have you consulted any specialists for your pain, and have you tried any alternative therapies? If so, how effective have they been?\n",
|
114 |
+
"Model: Finally, let's assess the functional impact of your headache. How has it affected your quality of life, your ability to perform daily activities, and your mood?\n",
|
115 |
+
"Model: To conclude, let's discuss your treatment goals and expectations. What are your hopes for managing this headache, and are there any alternative treatments you'd like to consider?\n",
|
116 |
+
"Model: Before we save this information, could you please review the data I've collected to ensure its accuracy? Is everything correct?\n",
|
117 |
+
"Your input data:\n",
|
118 |
+
" ID\n",
|
119 |
+
" symptom\n",
|
120 |
+
" pain\n",
|
121 |
+
" medical_hist\n",
|
122 |
+
" family_hist\n",
|
123 |
+
" social_hist\n",
|
124 |
+
" review_system\n",
|
125 |
+
" pain_manage\n",
|
126 |
+
" functional\n",
|
127 |
+
" plan\n",
|
128 |
"Saving the data!\n",
|
129 |
+
"plan\n"
|
130 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
],
|
133 |
"source": [
|
134 |
"# The default recursion limit for traversing nodes is 25 - setting it higher\n",
|
135 |
"# means you can try a more complex order with multiple steps and round-trips.\n",
|
136 |
+
"config = {\"recursion_limit\": 1000}\n",
|
137 |
"\n",
|
138 |
"# Uncomment this line to execute the graph:\n",
|
139 |
"# Clear output before running new states\n",
|
|
|
142 |
"# Ensure messages print immediately\n",
|
143 |
"print(\"Executing the chatbot graph...\", flush=True)\n",
|
144 |
"state = graph_with_order_tools.invoke({\"messages\": []}, config)\n",
|
145 |
+
"# display(state) # Ensures state is shown in Jupyter\n",
|
146 |
+
"# sys.stdout.flush()\n",
|
147 |
"\n",
|
148 |
"# pprint(state)"
|
149 |
]
|
150 |
},
|
151 |
{
|
152 |
"cell_type": "code",
|
153 |
+
"execution_count": 4,
|
154 |
"metadata": {
|
155 |
"trusted": true
|
156 |
},
|
|
|
158 |
{
|
159 |
"data": {
|
160 |
"text/plain": [
|
161 |
+
"'plan'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
]
|
163 |
},
|
164 |
"execution_count": 4,
|