xiaosuhu1986 commited on
Commit
95243ee
·
1 Parent(s): 7828fde

update: the full data section

Browse files
chat_hist_temp.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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.
2
+ Model: Great! First, I need some basic information for your medical record. Please tell me your full name, date of birth, gender, and contact number. Also, please provide an emergency contact name and number.
3
+ Model: Please provide your full name, date of birth, gender, and contact number. Also, please provide an emergency contact name and number. This information is essential to begin your intake.
4
+ Model: Thank you. Now, can you describe your main symptom or reason for seeking medical attention today? And how long have you been experiencing this?
5
+ Model: Okay. Let's move on to a pain assessment. To help me understand your headache, can you tell me where exactly you feel the pain? Is it on the left, right, or both sides? And on a scale of 0 to 10, with 0 being no pain and 10 being the worst pain imaginable, how intense is the pain right now?
6
+
7
+ We'll use a body map: head, arms, hands, trunk, legs, feet. Please indicate the location(s) of your pain.
8
+ Model: Please describe the location of your headache (e.g., forehead, temples, back of the head). Is it on the left, right, or both sides? And what is the pain intensity on a scale of 0-10? We need this information to continue with the assessment.
9
+ Model: Okay, so you're experiencing pain on the left side of your head, with an intensity of 2 out of 10. Can you describe the characteristics of the pain? Is it sharp, dull, throbbing, aching, or something else? When did the pain start? Does it radiate to any other areas? Are there any triggers that make it worse or better? Are there any other symptoms associated with the headache, such as nausea, vomiting, or visual disturbances?
10
+ Model: To continue, please describe the characteristics of your headache (sharp, dull, throbbing, etc.), when it started, if it radiates, any triggers, and any associated symptoms (nausea, vomiting, visual disturbances, etc.). This information is crucial for a proper assessment.
11
+ Model: Understood. Let's summarize what we have so far:
12
+
13
+ * **Patient:** Frank
14
+ * **DOB:** 1986-01-01
15
+ * **Main Symptom:** Headache on the left side of the head, sharp pain, intensity 2/10.
16
+ * **Duration:** 2 days
17
+ * **Triggers:** Cold temperatures seem to worsen the pain.
18
+ * **Associated Symptoms:** None reported.
19
+
20
+ Is this information correct so far?
21
+ Model: Great. Now, let's proceed with your medical history. Do you have any existing medical conditions? If so, please list them and when they were first diagnosed. Do you have any known allergies? Have you had any surgeries in the past? If so, please specify the dates and types of surgeries. What medications are you currently taking, including over-the-counter medications?
testtext_tmp → command_hist.txt RENAMED
File without changes
modules/data_class.py CHANGED
@@ -32,10 +32,12 @@ class PatientID(TypedDict):
32
 
33
  class MainSymptom(TypedDict):
34
  main_symptom: str
35
- length: str
36
 
37
  class Pain(TypedDict):
38
- painlevel: PainLevels
 
 
39
  pain_description: str
40
  start_time: date
41
  radiation: bool
@@ -87,15 +89,15 @@ class Plan(TypedDict):
87
 
88
  class PatientData(TypedDict):
89
  ID: PatientID
90
- main: MainSymptom
91
- """pain: Pain
92
  medical_hist: MedicalHistory
93
  family_hist: FamilyHistory
94
  social_hist: SocialHistory
95
  review_system: ReviewSystem
96
  pain_manage: PainManagement
97
  functional: Functional
98
- plan: Plan"""
99
 
100
  class DataState(TypedDict):
101
  """State representing the patient's data status and conversation."""
 
32
 
33
  class MainSymptom(TypedDict):
34
  main_symptom: str
35
+ symptom_length: str
36
 
37
  class Pain(TypedDict):
38
+ pain_location: str
39
+ pain_side: str
40
+ pain_intensity: int
41
  pain_description: str
42
  start_time: date
43
  radiation: bool
 
89
 
90
  class PatientData(TypedDict):
91
  ID: PatientID
92
+ symptom: MainSymptom
93
+ pain: Pain
94
  medical_hist: MedicalHistory
95
  family_hist: FamilyHistory
96
  social_hist: SocialHistory
97
  review_system: ReviewSystem
98
  pain_manage: PainManagement
99
  functional: Functional
100
+ plan: Plan
101
 
102
  class DataState(TypedDict):
103
  """State representing the patient's data status and conversation."""
modules/instrctions.py CHANGED
@@ -16,6 +16,7 @@ MEDICAL_INTAKE_SYSINT = (
16
 
17
  3. Pain Assessment
18
  - Pain location using body mapping (head, arms, hands, trunk, legs, feet)
 
19
  - Pain intensity (0-10 scale for each location)
20
  - Pain characteristics and patterns
21
  - Onset time
 
16
 
17
  3. Pain Assessment
18
  - Pain location using body mapping (head, arms, hands, trunk, legs, feet)
19
+ - Pain side (left or right)
20
  - Pain intensity (0-10 scale for each location)
21
  - Pain characteristics and patterns
22
  - Onset time
modules/llm_in_use.py CHANGED
@@ -12,7 +12,7 @@ def get_llm():
12
 
13
  # llm = ChatOpenAI(temperature=0)
14
 
15
- llm = ChatOllama(model="llama3.2:latest", temperature=0)
16
 
17
  """llm = ChatOpenAI(
18
  api_key="ollama",
@@ -20,6 +20,6 @@ def get_llm():
20
  base_url="http://141.211.127.171/",
21
  )"""
22
 
23
- # llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash-latest")
24
 
25
  return llm
 
12
 
13
  # llm = ChatOpenAI(temperature=0)
14
 
15
+ # llm = ChatOllama(model="llama3.2:latest", temperature=0)
16
 
17
  """llm = ChatOpenAI(
18
  api_key="ollama",
 
20
  base_url="http://141.211.127.171/",
21
  )"""
22
 
23
+ llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash-latest")
24
 
25
  return llm
modules/nodes.py CHANGED
@@ -49,10 +49,63 @@ def chatbot_with_tools(state: DataState) -> DataState:
49
  "contact": "",
50
  "emergency_contact": ""
51
  },
52
- "symptom": {
53
- "main_symptom": "",
54
- "length": ""
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }, "finished": False}
57
 
58
  if state["messages"]:
 
49
  "contact": "",
50
  "emergency_contact": ""
51
  },
52
+ "symptom": {
53
+ "main_symptom": "",
54
+ "symptom_length": ""
55
+ },
56
+ "pain": {
57
+ "pain_location": "",
58
+ "pain_side": "",
59
+ "pain_intensity": 0,
60
+ "pain_description": "",
61
+ "start_time": date(1900, 1, 1),
62
+ "radiation": False,
63
+ "triggers": "",
64
+ "symptom": ""
65
+ },
66
+ "medical_hist": {
67
+ "medical_condition": "",
68
+ "first_time": date(1900, 1, 1),
69
+ "surgery_history": [],
70
+ "medication": "",
71
+ "allergy": ""
72
+ },
73
+ "family_hist": {
74
+ "family_history": "",
75
+ },
76
+ "social_hist": {
77
+ "occupation": "",
78
+ "smoke": False,
79
+ "alcohol": False,
80
+ "drug": False,
81
+ "support_system": "",
82
+ "living_condition": "",
83
+ },
84
+ "reveiw_system": {
85
+ "weight_change": "",
86
+ "fever": False,
87
+ "chill": False,
88
+ "night_sweats": False,
89
+ "sleep": "",
90
+ "gastrointestinal": "",
91
+ "urinary": "",
92
+ },
93
+ "pain_manage": {
94
+ "pain_medication": "",
95
+ "specialist": False,
96
+ "other_therapy": "",
97
+ "effectiveness": False,
98
+ },
99
+ "functional": {
100
+ "life_quality": "",
101
+ "limit_activity": "",
102
+ "mood": "",
103
+ },
104
+ "plan": {
105
+ "goal": "",
106
+ "expectation": "",
107
+ "alternative_treatment_illness": "",
108
+ }
109
  }, "finished": False}
110
 
111
  if state["messages"]:
paintrek-chat-v2.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 1,
6
  "metadata": {
7
  "execution": {
8
  "iopub.execute_input": "2025-01-29T20:09:11.440091Z",
@@ -14,16 +14,7 @@
14
  "id": "xaiioUQni_ga",
15
  "trusted": true
16
  },
17
- "outputs": [
18
- {
19
- "name": "stderr",
20
- "output_type": "stream",
21
- "text": [
22
- "/home/frank-elite/miniconda3/envs/paintrekbot/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
23
- " from .autonotebook import tqdm as notebook_tqdm\n"
24
- ]
25
- }
26
- ],
27
  "source": [
28
  "from modules.data_class import DataState\n",
29
  "from modules.tools import data_node\n",
@@ -37,12 +28,14 @@
37
  "\n",
38
  "from langgraph.prebuilt import ToolNode\n",
39
  "\n",
40
- "from collections.abc import Iterable"
 
 
41
  ]
42
  },
43
  {
44
  "cell_type": "code",
45
- "execution_count": 2,
46
  "metadata": {
47
  "execution": {
48
  "iopub.execute_input": "2025-01-29T20:09:11.906458Z",
@@ -62,7 +55,7 @@
62
  "<IPython.core.display.Image object>"
63
  ]
64
  },
65
- "execution_count": 2,
66
  "metadata": {},
67
  "output_type": "execute_result"
68
  }
@@ -91,7 +84,7 @@
91
  },
92
  {
93
  "cell_type": "code",
94
- "execution_count": 3,
95
  "metadata": {
96
  "execution": {
97
  "iopub.execute_input": "2025-01-29T20:09:38.185616Z",
@@ -108,8 +101,54 @@
108
  "name": "stdout",
109
  "output_type": "stream",
110
  "text": [
 
111
  "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"
112
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
  ],
115
  "source": [
@@ -118,14 +157,21 @@
118
  "config = {\"recursion_limit\": 500}\n",
119
  "\n",
120
  "# Uncomment this line to execute the graph:\n",
 
 
 
 
 
121
  "state = graph_with_order_tools.invoke({\"messages\": []}, config)\n",
 
 
122
  "\n",
123
  "# pprint(state)"
124
  ]
125
  },
126
  {
127
  "cell_type": "code",
128
- "execution_count": 15,
129
  "metadata": {
130
  "trusted": true
131
  },
@@ -134,16 +180,16 @@
134
  "data": {
135
  "text/plain": [
136
  "{'ID': {'name': 'Frank',\n",
137
- " 'DOB': '1990-01-01',\n",
138
  " 'gender': 'male',\n",
139
- " 'contact': '123 Main St',\n",
140
- " 'emergency_contact': 'Jane Smith'},\n",
141
  " 'symptom': {'main_symptom': 'headache',\n",
142
  " 'length': '',\n",
143
- " 'symptom_length': '2 weeks'}}"
144
  ]
145
  },
146
- "execution_count": 15,
147
  "metadata": {},
148
  "output_type": "execute_result"
149
  }
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 4,
6
  "metadata": {
7
  "execution": {
8
  "iopub.execute_input": "2025-01-29T20:09:11.440091Z",
 
14
  "id": "xaiioUQni_ga",
15
  "trusted": true
16
  },
17
+ "outputs": [],
 
 
 
 
 
 
 
 
 
18
  "source": [
19
  "from modules.data_class import DataState\n",
20
  "from modules.tools import data_node\n",
 
28
  "\n",
29
  "from langgraph.prebuilt import ToolNode\n",
30
  "\n",
31
+ "from collections.abc import Iterable\n",
32
+ "from IPython.display import display, clear_output\n",
33
+ "import sys"
34
  ]
35
  },
36
  {
37
  "cell_type": "code",
38
+ "execution_count": 5,
39
  "metadata": {
40
  "execution": {
41
  "iopub.execute_input": "2025-01-29T20:09:11.906458Z",
 
55
  "<IPython.core.display.Image object>"
56
  ]
57
  },
58
+ "execution_count": 5,
59
  "metadata": {},
60
  "output_type": "execute_result"
61
  }
 
84
  },
85
  {
86
  "cell_type": "code",
87
+ "execution_count": 6,
88
  "metadata": {
89
  "execution": {
90
  "iopub.execute_input": "2025-01-29T20:09:38.185616Z",
 
101
  "name": "stdout",
102
  "output_type": "stream",
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
  ]
107
+ },
108
+ {
109
+ "name": "stdout",
110
+ "output_type": "stream",
111
+ "text": [
112
+ "Model: Great! First, I need some basic information for your medical record. Please tell me your full name, date of birth, gender, and contact number. Also, please provide an emergency contact name and number.\n",
113
+ "Model: Please provide your full name, date of birth, gender, and contact number. Also, please provide an emergency contact name and number. This information is essential to begin your intake.\n",
114
+ "Model: Thank you. Now, can you describe your main symptom or reason for seeking medical attention today? And how long have you been experiencing this?\n",
115
+ "Model: Okay. Let's move on to a pain assessment. To help me understand your headache, can you tell me where exactly you feel the pain? Is it on the left, right, or both sides? And on a scale of 0 to 10, with 0 being no pain and 10 being the worst pain imaginable, how intense is the pain right now?\n",
116
+ "\n",
117
+ "We'll use a body map: head, arms, hands, trunk, legs, feet. Please indicate the location(s) of your pain.\n",
118
+ "Model: Please describe the location of your headache (e.g., forehead, temples, back of the head). Is it on the left, right, or both sides? And what is the pain intensity on a scale of 0-10? We need this information to continue with the assessment.\n",
119
+ "Model: Okay, so you're experiencing pain on the left side of your head, with an intensity of 2 out of 10. Can you describe the characteristics of the pain? Is it sharp, dull, throbbing, aching, or something else? When did the pain start? Does it radiate to any other areas? Are there any triggers that make it worse or better? Are there any other symptoms associated with the headache, such as nausea, vomiting, or visual disturbances?\n",
120
+ "Model: To continue, please describe the characteristics of your headache (sharp, dull, throbbing, etc.), when it started, if it radiates, any triggers, and any associated symptoms (nausea, vomiting, visual disturbances, etc.). This information is crucial for a proper assessment.\n",
121
+ "Model: Understood. Let's summarize what we have so far:\n",
122
+ "\n",
123
+ "* **Patient:** Frank\n",
124
+ "* **DOB:** 1986-01-01\n",
125
+ "* **Main Symptom:** Headache on the left side of the head, sharp pain, intensity 2/10.\n",
126
+ "* **Duration:** 2 days\n",
127
+ "* **Triggers:** Cold temperatures seem to worsen the pain.\n",
128
+ "* **Associated Symptoms:** None reported.\n",
129
+ "\n",
130
+ "Is this information correct so far?\n",
131
+ "Model: Great. Now, let's proceed with your medical history. Do you have any existing medical conditions? If so, please list them and when they were first diagnosed. Do you have any known allergies? Have you had any surgeries in the past? If so, please specify the dates and types of surgeries. What medications are you currently taking, including over-the-counter medications?\n"
132
+ ]
133
+ },
134
+ {
135
+ "ename": "NotImplementedError",
136
+ "evalue": "Unknown tool call: add_to_data",
137
+ "output_type": "error",
138
+ "traceback": [
139
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
140
+ "\u001b[0;31mNotImplementedError\u001b[0m Traceback (most recent call last)",
141
+ "Cell \u001b[0;32mIn[6], line 11\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;66;03m# Ensure messages print immediately\u001b[39;00m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExecuting the chatbot graph...\u001b[39m\u001b[38;5;124m\"\u001b[39m, flush\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 11\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: []}, config)\n\u001b[1;32m 12\u001b[0m display(state) \u001b[38;5;66;03m# Ensures state is shown in Jupyter\u001b[39;00m\n\u001b[1;32m 13\u001b[0m sys\u001b[38;5;241m.\u001b[39mstdout\u001b[38;5;241m.\u001b[39mflush()\n",
142
+ "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",
143
+ "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",
144
+ "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",
145
+ "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",
146
+ "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",
147
+ "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",
148
+ "File \u001b[0;32m/media/frank-elite/Application/PythonProj/LangGraphExampleResume/modules/tools.py:136\u001b[0m, in \u001b[0;36mdata_node\u001b[0;34m(state)\u001b[0m\n\u001b[1;32m 132\u001b[0m data_saved \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m 133\u001b[0m \u001b[38;5;66;03m# response = randint(1, 5) # ETA in minutes\u001b[39;00m\n\u001b[1;32m 134\u001b[0m \n\u001b[1;32m 135\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 136\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mUnknown tool call: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mtool_call[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 138\u001b[0m \u001b[38;5;66;03m# Record the tool results as tool messages.\u001b[39;00m\n\u001b[1;32m 139\u001b[0m outbound_msgs\u001b[38;5;241m.\u001b[39mappend(\n\u001b[1;32m 140\u001b[0m ToolMessage(\n\u001b[1;32m 141\u001b[0m content\u001b[38;5;241m=\u001b[39mresponse,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 144\u001b[0m )\n\u001b[1;32m 145\u001b[0m )\n",
149
+ "\u001b[0;31mNotImplementedError\u001b[0m: Unknown tool call: add_to_data",
150
+ "\u001b[0mDuring task with name 'documenting' and id '88c3029c-c38b-1204-cc25-5e2214e0b1ab'"
151
+ ]
152
  }
153
  ],
154
  "source": [
 
157
  "config = {\"recursion_limit\": 500}\n",
158
  "\n",
159
  "# Uncomment this line to execute the graph:\n",
160
+ "# Clear output before running new states\n",
161
+ "clear_output(wait=True)\n",
162
+ "\n",
163
+ "# Ensure messages print immediately\n",
164
+ "print(\"Executing the chatbot graph...\", flush=True)\n",
165
  "state = graph_with_order_tools.invoke({\"messages\": []}, config)\n",
166
+ "display(state) # Ensures state is shown in Jupyter\n",
167
+ "sys.stdout.flush()\n",
168
  "\n",
169
  "# pprint(state)"
170
  ]
171
  },
172
  {
173
  "cell_type": "code",
174
+ "execution_count": null,
175
  "metadata": {
176
  "trusted": true
177
  },
 
180
  "data": {
181
  "text/plain": [
182
  "{'ID': {'name': 'Frank',\n",
183
+ " 'DOB': '1986-01-01',\n",
184
  " 'gender': 'male',\n",
185
+ " 'contact': '12345',\n",
186
+ " 'emergency_contact': 'Zoe, 67890'},\n",
187
  " 'symptom': {'main_symptom': 'headache',\n",
188
  " 'length': '',\n",
189
+ " 'symptom_length': 'a week'}}"
190
  ]
191
  },
192
+ "execution_count": 5,
193
  "metadata": {},
194
  "output_type": "execute_result"
195
  }