Commit
·
7828fde
1
Parent(s):
3e595a5
update: minor package path update
Browse files- modules/data_class.py +2 -0
- modules/nodes.py +3 -2
- paintrek-chat-v1.ipynb +1 -1
- paintrek-chat-v2.ipynb +11 -46
modules/data_class.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
from typing_extensions import TypedDict
|
2 |
from datetime import date
|
3 |
from typing import Annotated, Dict, Any
|
|
|
|
|
4 |
|
5 |
|
6 |
class PainLevels(TypedDict):
|
|
|
1 |
from typing_extensions import TypedDict
|
2 |
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):
|
modules/nodes.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
from modules.data_class import DataState
|
2 |
from modules.instrctions import MEDICAL_INTAKE_SYSINT, WELCOME_MSG
|
|
|
|
|
|
|
3 |
from datetime import date
|
4 |
from typing import Literal
|
5 |
from langgraph.graph import StateGraph, START, END
|
6 |
from langchain_core.messages.ai import AIMessage
|
7 |
-
from llm_in_use import get_llm
|
8 |
-
from tools import patient_id, symptom, confirm_data, get_data, clear_data, save_data, data_node
|
9 |
|
10 |
|
11 |
llm = get_llm()
|
|
|
1 |
from modules.data_class import DataState
|
2 |
from modules.instrctions import MEDICAL_INTAKE_SYSINT, WELCOME_MSG
|
3 |
+
from modules.llm_in_use import get_llm
|
4 |
+
from modules.tools import patient_id, symptom, confirm_data, get_data, clear_data, save_data
|
5 |
+
|
6 |
from datetime import date
|
7 |
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()
|
paintrek-chat-v1.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",
|
|
|
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",
|
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",
|
@@ -16,27 +16,19 @@
|
|
16 |
},
|
17 |
"outputs": [
|
18 |
{
|
19 |
-
"
|
20 |
-
"
|
21 |
-
"
|
22 |
-
|
23 |
-
"\
|
24 |
-
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
25 |
-
"Cell \u001b[0;32mIn[12], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mmodules\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdata_class\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m DataState\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtools\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m data_node\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mnodes\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m chatbot_with_tools, human_node, maybe_exit_human_node, maybe_route_to_tools\n",
|
26 |
-
"File \u001b[0;32m/media/frank-elite/Application/PythonProj/LangGraphExampleResume/modules/data_class.py:98\u001b[0m\n\u001b[1;32m 88\u001b[0m main: MainSymptom\n\u001b[1;32m 89\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"pain: Pain\u001b[39;00m\n\u001b[1;32m 90\u001b[0m \u001b[38;5;124;03m medical_hist: MedicalHistory\u001b[39;00m\n\u001b[1;32m 91\u001b[0m \u001b[38;5;124;03m family_hist: FamilyHistory\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 95\u001b[0m \u001b[38;5;124;03m functional: Functional\u001b[39;00m\n\u001b[1;32m 96\u001b[0m \u001b[38;5;124;03m plan: Plan\"\"\"\u001b[39;00m\n\u001b[0;32m---> 98\u001b[0m \u001b[38;5;28;01mclass\u001b[39;00m \u001b[38;5;21;01mDataState\u001b[39;00m(TypedDict):\n\u001b[1;32m 99\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"State representing the patient's data status and conversation.\"\"\"\u001b[39;00m\n\u001b[1;32m 100\u001b[0m messages: Annotated[\u001b[38;5;28mlist\u001b[39m, add_messages]\n",
|
27 |
-
"File \u001b[0;32m/media/frank-elite/Application/PythonProj/LangGraphExampleResume/modules/data_class.py:100\u001b[0m, in \u001b[0;36mDataState\u001b[0;34m()\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[38;5;28;01mclass\u001b[39;00m \u001b[38;5;21;01mDataState\u001b[39;00m(TypedDict):\n\u001b[1;32m 99\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"State representing the patient's data status and conversation.\"\"\"\u001b[39;00m\n\u001b[0;32m--> 100\u001b[0m messages: Annotated[\u001b[38;5;28mlist\u001b[39m, add_messages]\n\u001b[1;32m 101\u001b[0m data: Dict[\u001b[38;5;28mstr\u001b[39m, PatientData]\n\u001b[1;32m 102\u001b[0m finished: \u001b[38;5;28mbool\u001b[39m\n",
|
28 |
-
"\u001b[0;31mNameError\u001b[0m: name 'add_messages' is not defined"
|
29 |
]
|
30 |
}
|
31 |
],
|
32 |
"source": [
|
33 |
-
"\n",
|
34 |
-
"\n",
|
35 |
"from modules.data_class import DataState\n",
|
36 |
-
"from tools import data_node\n",
|
37 |
-
"from nodes import chatbot_with_tools, human_node, maybe_exit_human_node, maybe_route_to_tools\n",
|
38 |
"\n",
|
39 |
-
"from langgraph.graph.message import add_messages\n",
|
40 |
"from langgraph.graph import StateGraph, START, END\n",
|
41 |
"\n",
|
42 |
"from IPython.display import Image, display\n",
|
@@ -50,7 +42,7 @@
|
|
50 |
},
|
51 |
{
|
52 |
"cell_type": "code",
|
53 |
-
"execution_count":
|
54 |
"metadata": {
|
55 |
"execution": {
|
56 |
"iopub.execute_input": "2025-01-29T20:09:11.906458Z",
|
@@ -70,7 +62,7 @@
|
|
70 |
"<IPython.core.display.Image object>"
|
71 |
]
|
72 |
},
|
73 |
-
"execution_count":
|
74 |
"metadata": {},
|
75 |
"output_type": "execute_result"
|
76 |
}
|
@@ -99,7 +91,7 @@
|
|
99 |
},
|
100 |
{
|
101 |
"cell_type": "code",
|
102 |
-
"execution_count":
|
103 |
"metadata": {
|
104 |
"execution": {
|
105 |
"iopub.execute_input": "2025-01-29T20:09:38.185616Z",
|
@@ -118,33 +110,6 @@
|
|
118 |
"text": [
|
119 |
"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"
|
120 |
]
|
121 |
-
},
|
122 |
-
{
|
123 |
-
"name": "stdout",
|
124 |
-
"output_type": "stream",
|
125 |
-
"text": [
|
126 |
-
"Model: I apologize for the format. Let's start again.\n",
|
127 |
-
"\n",
|
128 |
-
"Hello, my name is MedAssist, and I'll be guiding you through a structured data collection process to gather comprehensive patient information. Please feel free to share any concerns or symptoms you're experiencing.\n",
|
129 |
-
"\n",
|
130 |
-
"To begin, can you please tell me your full name?\n",
|
131 |
-
"Model: I think there's been a mistake! Let's start again from the beginning.\n",
|
132 |
-
"\n",
|
133 |
-
"Hello, my name is MedAssist, and I'll be guiding you through a structured data collection process to gather comprehensive patient information. Please feel free to share any concerns or symptoms you're experiencing.\n",
|
134 |
-
"\n",
|
135 |
-
"To confirm, your full name is indeed John Doe, as per our initial introduction. Is that correct?\n",
|
136 |
-
"Model: Thank you for correcting me, Frank. I've updated your patient information.\n",
|
137 |
-
"\n",
|
138 |
-
"Now, let's move on to the next step. Can you please tell me what brings you here today? What seems to be the main reason for your visit? Is it related to any specific symptoms or concerns you're experiencing?\n",
|
139 |
-
"Model: Thank you for sharing that with me, Frank. A headache can be quite uncomfortable.\n",
|
140 |
-
"\n",
|
141 |
-
"Can you please tell me more about your headache? Where exactly is the pain located on a scale of 0 to 10, with 0 being no pain at all and 10 being the worst possible pain?\n",
|
142 |
-
"\n",
|
143 |
-
"Also, how long have you been experiencing this headache? Was it sudden or did it come on gradually?\n",
|
144 |
-
"Model: I apologize if I lost you for a moment. Can you please tell me more about your headache? Where exactly is the pain located on a scale of 0 to 10, with 0 being no pain at all and 10 being the worst possible pain?\n",
|
145 |
-
"\n",
|
146 |
-
"Also, how long have you been experiencing this headache? Was it sudden or did it come on gradually?\n"
|
147 |
-
]
|
148 |
}
|
149 |
],
|
150 |
"source": [
|
|
|
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",
|
|
|
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",
|
30 |
+
"from modules.nodes import chatbot_with_tools, human_node, maybe_exit_human_node, maybe_route_to_tools\n",
|
31 |
"\n",
|
|
|
32 |
"from langgraph.graph import StateGraph, START, END\n",
|
33 |
"\n",
|
34 |
"from IPython.display import Image, display\n",
|
|
|
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 |
"<IPython.core.display.Image object>"
|
63 |
]
|
64 |
},
|
65 |
+
"execution_count": 2,
|
66 |
"metadata": {},
|
67 |
"output_type": "execute_result"
|
68 |
}
|
|
|
91 |
},
|
92 |
{
|
93 |
"cell_type": "code",
|
94 |
+
"execution_count": 3,
|
95 |
"metadata": {
|
96 |
"execution": {
|
97 |
"iopub.execute_input": "2025-01-29T20:09:38.185616Z",
|
|
|
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": [
|