Spaces:
Sleeping
Sleeping
Commit
·
62f919c
1
Parent(s):
f52aa71
Update: the tools func and nodes func
Browse files- chat_hist_temp.txt +9 -21
- modules/data_class.py +0 -2
- modules/nodes.py +0 -2
- modules/tools.py +3 -3
- paintrek-chat-v2.ipynb +22 -47
chat_hist_temp.txt
CHANGED
@@ -1,21 +1,9 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
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?
|
|
|
1 |
+
Let's start
|
2 |
+
I am Frank, DOB 1986-01-01, male, phone number is 12345, emergency name is Zoe, number is 67890.
|
3 |
+
I had a headache, and it started two days ago.
|
4 |
+
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.
|
5 |
+
I had sinus, diagnosed in 2001-01-01, I did not have any surgery. I am taking ibprofin, no allergies.
|
6 |
+
My mom had a lung cancer at 45.
|
7 |
+
I am a data scientist, I am a viggie. I don't use tobbaco or alcohol. My stress level is midium.
|
8 |
+
I sleep well, and no other symptoms.
|
9 |
+
No, I am not taking any other medication, and I haven't tried any alternative therapies.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modules/data_class.py
CHANGED
@@ -3,8 +3,6 @@ from datetime import date
|
|
3 |
from typing import Annotated, Dict, Any
|
4 |
from langgraph.graph.message import add_messages
|
5 |
|
6 |
-
|
7 |
-
|
8 |
class PainLevels(TypedDict):
|
9 |
left_head: int
|
10 |
right_head: int
|
|
|
3 |
from typing import Annotated, Dict, Any
|
4 |
from langgraph.graph.message import add_messages
|
5 |
|
|
|
|
|
6 |
class PainLevels(TypedDict):
|
7 |
left_head: int
|
8 |
right_head: int
|
modules/nodes.py
CHANGED
@@ -8,7 +8,6 @@ from typing import Literal
|
|
8 |
from langgraph.graph import StateGraph, START, END
|
9 |
from langchain_core.messages.ai import AIMessage
|
10 |
|
11 |
-
|
12 |
llm = get_llm()
|
13 |
# Order-tools will be handled by the order node.
|
14 |
intake_tools = [patient_id, symptom, confirm_data, get_data, clear_data, save_data]
|
@@ -16,7 +15,6 @@ intake_tools = [patient_id, symptom, confirm_data, get_data, clear_data, save_da
|
|
16 |
# The LLM needs to know about all of the tools, so specify everything here.
|
17 |
llm_with_tools = llm.bind_tools(intake_tools)
|
18 |
|
19 |
-
|
20 |
def human_node(state: DataState) -> DataState:
|
21 |
"""Display the last model message to the user, and receive the user's input."""
|
22 |
last_msg = state["messages"][-1]
|
|
|
8 |
from langgraph.graph import StateGraph, START, END
|
9 |
from langchain_core.messages.ai import AIMessage
|
10 |
|
|
|
11 |
llm = get_llm()
|
12 |
# Order-tools will be handled by the order node.
|
13 |
intake_tools = [patient_id, symptom, confirm_data, get_data, clear_data, save_data]
|
|
|
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 |
def human_node(state: DataState) -> DataState:
|
19 |
"""Display the last model message to the user, and receive the user's input."""
|
20 |
last_msg = state["messages"][-1]
|
modules/tools.py
CHANGED
@@ -46,7 +46,7 @@ def pain(pain_location: str, pain_side: str, pain_intensity: int, pain_descripti
|
|
46 |
Returns:
|
47 |
The updated data with the patient's pain status added.
|
48 |
"""
|
49 |
-
|
50 |
@tool
|
51 |
def medical_hist(medical_condition: str, first_time: str, surgery_history: list, medication: str, allergy: str) -> str:
|
52 |
"""Collecting patient's medical history including:
|
@@ -174,7 +174,7 @@ def data_node(state: DataState) -> DataState:
|
|
174 |
elif tool_call["name"] == "symptom":
|
175 |
# Each order item is just a string. This is where it assembled as "drink (modifiers, ...)".
|
176 |
data["symptom"]["main_symptom"]=tool_call["args"]["main_symptom"]
|
177 |
-
data["symptom"]["symptom_length"]=tool_call["args"]["
|
178 |
response = "\n".join(data)
|
179 |
|
180 |
elif tool_call["name"] == "pain":
|
@@ -270,7 +270,7 @@ def data_node(state: DataState) -> DataState:
|
|
270 |
|
271 |
#order_text = "\n".join(order)
|
272 |
print("Saving the data!")
|
273 |
-
|
274 |
|
275 |
# TODO(you!): Implement cafe.
|
276 |
data_saved = True
|
|
|
46 |
Returns:
|
47 |
The updated data with the patient's pain status added.
|
48 |
"""
|
49 |
+
|
50 |
@tool
|
51 |
def medical_hist(medical_condition: str, first_time: str, surgery_history: list, medication: str, allergy: str) -> str:
|
52 |
"""Collecting patient's medical history including:
|
|
|
174 |
elif tool_call["name"] == "symptom":
|
175 |
# Each order item is just a string. This is where it assembled as "drink (modifiers, ...)".
|
176 |
data["symptom"]["main_symptom"]=tool_call["args"]["main_symptom"]
|
177 |
+
data["symptom"]["symptom_length"]=tool_call["args"]["symptom_length"]
|
178 |
response = "\n".join(data)
|
179 |
|
180 |
elif tool_call["name"] == "pain":
|
|
|
270 |
|
271 |
#order_text = "\n".join(order)
|
272 |
print("Saving the data!")
|
273 |
+
print(data)
|
274 |
|
275 |
# TODO(you!): Implement cafe.
|
276 |
data_saved = True
|
paintrek-chat-v2.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {
|
7 |
"execution": {
|
8 |
"iopub.execute_input": "2025-01-29T20:09:11.440091Z",
|
@@ -35,7 +35,7 @@
|
|
35 |
},
|
36 |
{
|
37 |
"cell_type": "code",
|
38 |
-
"execution_count":
|
39 |
"metadata": {
|
40 |
"execution": {
|
41 |
"iopub.execute_input": "2025-01-29T20:09:11.906458Z",
|
@@ -55,7 +55,7 @@
|
|
55 |
"<IPython.core.display.Image object>"
|
56 |
]
|
57 |
},
|
58 |
-
"execution_count":
|
59 |
"metadata": {},
|
60 |
"output_type": "execute_result"
|
61 |
}
|
@@ -84,7 +84,7 @@
|
|
84 |
},
|
85 |
{
|
86 |
"cell_type": "code",
|
87 |
-
"execution_count":
|
88 |
"metadata": {
|
89 |
"execution": {
|
90 |
"iopub.execute_input": "2025-01-29T20:09:38.185616Z",
|
@@ -102,52 +102,27 @@
|
|
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": "
|
136 |
-
"evalue": "
|
137 |
"output_type": "error",
|
138 |
"traceback": [
|
139 |
-
"\u001b[
|
140 |
-
"\u001b[
|
141 |
-
"Cell \u001b[
|
142 |
-
"File \u001b[
|
143 |
-
"File \u001b[
|
144 |
-
"File \u001b[
|
145 |
-
"File \u001b[
|
146 |
-
"File \u001b[
|
147 |
-
"File \u001b[
|
148 |
-
"File \u001b[
|
149 |
-
"\u001b[
|
150 |
-
"\u001b[0mDuring task with name 'documenting' and id '88c3029c-c38b-1204-cc25-5e2214e0b1ab'"
|
151 |
]
|
152 |
}
|
153 |
],
|
@@ -221,7 +196,7 @@
|
|
221 |
"sourceType": "notebook"
|
222 |
},
|
223 |
"kernelspec": {
|
224 |
-
"display_name": "
|
225 |
"language": "python",
|
226 |
"name": "python3"
|
227 |
},
|
@@ -235,7 +210,7 @@
|
|
235 |
"name": "python",
|
236 |
"nbconvert_exporter": "python",
|
237 |
"pygments_lexer": "ipython3",
|
238 |
-
"version": "3.
|
239 |
}
|
240 |
},
|
241 |
"nbformat": 4,
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 9,
|
6 |
"metadata": {
|
7 |
"execution": {
|
8 |
"iopub.execute_input": "2025-01-29T20:09:11.440091Z",
|
|
|
35 |
},
|
36 |
{
|
37 |
"cell_type": "code",
|
38 |
+
"execution_count": 10,
|
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": 10,
|
59 |
"metadata": {},
|
60 |
"output_type": "execute_result"
|
61 |
}
|
|
|
84 |
},
|
85 |
{
|
86 |
"cell_type": "code",
|
87 |
+
"execution_count": 11,
|
88 |
"metadata": {
|
89 |
"execution": {
|
90 |
"iopub.execute_input": "2025-01-29T20:09:38.185616Z",
|
|
|
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 |
+
"Model: Great! First, I need some basic information for your record. Please tell me your full name, date of birth (MM/DD/YYYY), gender, and contact phone number. Also, please provide the name and phone number of your emergency contact.\n",
|
107 |
+
"Model: Thank you. Now, can you describe your main symptom or the reason for your visit today? And how long have you been experiencing this?\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
]
|
109 |
},
|
110 |
{
|
111 |
+
"ename": "KeyError",
|
112 |
+
"evalue": "'length'",
|
113 |
"output_type": "error",
|
114 |
"traceback": [
|
115 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
116 |
+
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
|
117 |
+
"Cell \u001b[1;32mIn[11], line 11\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[38;5;66;03m# Ensure messages print immediately\u001b[39;00m\n\u001b[0;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[1;32m---> 11\u001b[0m state \u001b[38;5;241m=\u001b[39m \u001b[43mgraph_with_order_tools\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmessages\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 12\u001b[0m display(state) \u001b[38;5;66;03m# Ensures state is shown in Jupyter\u001b[39;00m\n\u001b[0;32m 13\u001b[0m sys\u001b[38;5;241m.\u001b[39mstdout\u001b[38;5;241m.\u001b[39mflush()\n",
|
118 |
+
"File \u001b[1;32md:\\miniconda3\\envs\\paintrek\\lib\\site-packages\\langgraph\\pregel\\__init__.py:1961\u001b[0m, in \u001b[0;36mPregel.invoke\u001b[1;34m(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug, **kwargs)\u001b[0m\n\u001b[0;32m 1959\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 1960\u001b[0m chunks \u001b[38;5;241m=\u001b[39m []\n\u001b[1;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[0;32m 1962\u001b[0m \u001b[38;5;28minput\u001b[39m,\n\u001b[0;32m 1963\u001b[0m config,\n\u001b[0;32m 1964\u001b[0m stream_mode\u001b[38;5;241m=\u001b[39mstream_mode,\n\u001b[0;32m 1965\u001b[0m output_keys\u001b[38;5;241m=\u001b[39moutput_keys,\n\u001b[0;32m 1966\u001b[0m interrupt_before\u001b[38;5;241m=\u001b[39minterrupt_before,\n\u001b[0;32m 1967\u001b[0m interrupt_after\u001b[38;5;241m=\u001b[39minterrupt_after,\n\u001b[0;32m 1968\u001b[0m debug\u001b[38;5;241m=\u001b[39mdebug,\n\u001b[0;32m 1969\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[0;32m 1970\u001b[0m ):\n\u001b[0;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[0;32m 1972\u001b[0m latest \u001b[38;5;241m=\u001b[39m chunk\n",
|
119 |
+
"File \u001b[1;32md:\\miniconda3\\envs\\paintrek\\lib\\site-packages\\langgraph\\pregel\\__init__.py:1670\u001b[0m, in \u001b[0;36mPregel.stream\u001b[1;34m(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug, subgraphs)\u001b[0m\n\u001b[0;32m 1664\u001b[0m \u001b[38;5;66;03m# Similarly to Bulk Synchronous Parallel / Pregel model\u001b[39;00m\n\u001b[0;32m 1665\u001b[0m \u001b[38;5;66;03m# computation proceeds in steps, while there are channel updates.\u001b[39;00m\n\u001b[0;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[0;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[0;32m 1668\u001b[0m \u001b[38;5;66;03m# with channel updates applied only at the transition between steps.\u001b[39;00m\n\u001b[0;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[1;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[0;32m 1671\u001b[0m loop\u001b[38;5;241m.\u001b[39mtasks\u001b[38;5;241m.\u001b[39mvalues(),\n\u001b[0;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[0;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[0;32m 1674\u001b[0m get_waiter\u001b[38;5;241m=\u001b[39mget_waiter,\n\u001b[0;32m 1675\u001b[0m ):\n\u001b[0;32m 1676\u001b[0m \u001b[38;5;66;03m# emit output\u001b[39;00m\n\u001b[0;32m 1677\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m output()\n\u001b[0;32m 1678\u001b[0m \u001b[38;5;66;03m# emit output\u001b[39;00m\n",
|
120 |
+
"File \u001b[1;32md:\\miniconda3\\envs\\paintrek\\lib\\site-packages\\langgraph\\pregel\\runner.py:230\u001b[0m, in \u001b[0;36mPregelRunner.tick\u001b[1;34m(self, tasks, reraise, timeout, retry_policy, get_waiter)\u001b[0m\n\u001b[0;32m 228\u001b[0m t \u001b[38;5;241m=\u001b[39m tasks[\u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m 229\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 230\u001b[0m \u001b[43mrun_with_retry\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 231\u001b[0m \u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 232\u001b[0m \u001b[43m \u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 233\u001b[0m \u001b[43m \u001b[49m\u001b[43mconfigurable\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\n\u001b[0;32m 234\u001b[0m \u001b[43m \u001b[49m\u001b[43mCONFIG_KEY_SEND\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpartial\u001b[49m\u001b[43m(\u001b[49m\u001b[43mwriter\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 235\u001b[0m \u001b[43m \u001b[49m\u001b[43mCONFIG_KEY_CALL\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpartial\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcall\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 236\u001b[0m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 237\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;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[0;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",
|
121 |
+
"File \u001b[1;32md:\\miniconda3\\envs\\paintrek\\lib\\site-packages\\langgraph\\pregel\\retry.py:40\u001b[0m, in \u001b[0;36mrun_with_retry\u001b[1;34m(task, retry_policy, configurable)\u001b[0m\n\u001b[0;32m 38\u001b[0m task\u001b[38;5;241m.\u001b[39mwrites\u001b[38;5;241m.\u001b[39mclear()\n\u001b[0;32m 39\u001b[0m \u001b[38;5;66;03m# run the task\u001b[39;00m\n\u001b[1;32m---> 40\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtask\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mproc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtask\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minput\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 41\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ParentCommand \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[0;32m 42\u001b[0m ns: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m config[CONF][CONFIG_KEY_CHECKPOINT_NS]\n",
|
122 |
+
"File \u001b[1;32md:\\miniconda3\\envs\\paintrek\\lib\\site-packages\\langgraph\\utils\\runnable.py:462\u001b[0m, in \u001b[0;36mRunnableSeq.invoke\u001b[1;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[0;32m 458\u001b[0m config \u001b[38;5;241m=\u001b[39m patch_config(\n\u001b[0;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[0;32m 460\u001b[0m )\n\u001b[0;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[1;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[0;32m 463\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;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",
|
123 |
+
"File \u001b[1;32md:\\miniconda3\\envs\\paintrek\\lib\\site-packages\\langgraph\\utils\\runnable.py:226\u001b[0m, in \u001b[0;36mRunnableCallable.invoke\u001b[1;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[0;32m 224\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 225\u001b[0m context\u001b[38;5;241m.\u001b[39mrun(_set_config_context, config)\n\u001b[1;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[0;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[0;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",
|
124 |
+
"File \u001b[1;32md:\\PythonProjs\\PainTrek_Chatbot\\modules\\tools.py:177\u001b[0m, in \u001b[0;36mdata_node\u001b[1;34m(state)\u001b[0m\n\u001b[0;32m 174\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m tool_call[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msymptom\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m 175\u001b[0m \u001b[38;5;66;03m# Each order item is just a string. This is where it assembled as \"drink (modifiers, ...)\".\u001b[39;00m\n\u001b[0;32m 176\u001b[0m data[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msymptom\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmain_symptom\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m=\u001b[39mtool_call[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124margs\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmain_symptom\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m--> 177\u001b[0m data[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msymptom\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msymptom_length\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m=\u001b[39m\u001b[43mtool_call\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43margs\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlength\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[0;32m 178\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(data)\n\u001b[0;32m 180\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m tool_call[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpain\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n",
|
125 |
+
"\u001b[1;31mKeyError\u001b[0m: 'length'"
|
|
|
126 |
]
|
127 |
}
|
128 |
],
|
|
|
196 |
"sourceType": "notebook"
|
197 |
},
|
198 |
"kernelspec": {
|
199 |
+
"display_name": "paintrek",
|
200 |
"language": "python",
|
201 |
"name": "python3"
|
202 |
},
|
|
|
210 |
"name": "python",
|
211 |
"nbconvert_exporter": "python",
|
212 |
"pygments_lexer": "ipython3",
|
213 |
+
"version": "3.10.13"
|
214 |
}
|
215 |
},
|
216 |
"nbformat": 4,
|