xiaosuhu1986 commited on
Commit
90f1f18
·
1 Parent(s): 95243ee

update tools functions

Browse files
command_hist.txt CHANGED
@@ -1,3 +1 @@
1
- I am Frank, DOB 1986-01-01, male, number 12345, emergency contact is Zoe, 67890.
2
-
3
  curl -X POST http://141.211.127.171/api/generate -H "Content-Type: application/json" -d '{"model":"llama3.2:latest","prompt": "Hello"}'
 
 
 
1
  curl -X POST http://141.211.127.171/api/generate -H "Content-Type: application/json" -d '{"model":"llama3.2:latest","prompt": "Hello"}'
modules/instrctions.py CHANGED
@@ -60,10 +60,9 @@ MEDICAL_INTAKE_SYSINT = (
60
 
61
  Data Management Commands:
62
  - Use get_data to review current information
63
- - Use add_to_data to append new information
64
  - Use clear_data to reset the current session
65
  - Use confirm_data to verify information with the patient
66
- - Use insert_data to finalize the record
67
 
68
  Guidelines:
69
  1. Always introduce yourself and explain the intake process
 
60
 
61
  Data Management Commands:
62
  - Use get_data to review current information
 
63
  - Use clear_data to reset the current session
64
  - Use confirm_data to verify information with the patient
65
+ - Use save_data to save the record to the database
66
 
67
  Guidelines:
68
  1. Always introduce yourself and explain the intake process
modules/nodes.py CHANGED
@@ -81,7 +81,7 @@ def chatbot_with_tools(state: DataState) -> DataState:
81
  "support_system": "",
82
  "living_condition": "",
83
  },
84
- "reveiw_system": {
85
  "weight_change": "",
86
  "fever": False,
87
  "chill": False,
 
81
  "support_system": "",
82
  "living_condition": "",
83
  },
84
+ "review_system": {
85
  "weight_change": "",
86
  "fever": False,
87
  "chill": False,
modules/tools.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  from langchain_core.tools import tool
2
  from modules.data_class import DataState
3
  from langgraph.prebuilt import InjectedState
@@ -20,7 +22,7 @@ def patient_id(name: str, DOB: str, gender: str, contact: str, emergency_contact
20
  """
21
 
22
  @tool
23
- def symptom(main_symptom: str, length: str) -> str:
24
  """Collecting patient's main symptom assessment including:
25
  - Primary symptoms
26
  - Duration of the symptoms
@@ -29,6 +31,68 @@ def symptom(main_symptom: str, length: str) -> str:
29
  The updated data with the patient's symptom information added.
30
  """
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  @tool
34
  def confirm_data() -> str:
@@ -68,30 +132,38 @@ def data_node(state: DataState) -> DataState:
68
  for tool_call in tool_msg.tool_calls:
69
 
70
  if tool_call["name"] == "patient_id":
71
-
72
  # Each order item is just a string. This is where it assembled as "drink (modifiers, ...)".
73
- patient_name = tool_call["args"]["name"]
74
- patient_DOB = tool_call["args"]["DOB"]
75
- patient_gender = tool_call["args"]["gender"]
76
- patient_contact = tool_call["args"]["contact"]
77
- patient_emergency_contact = tool_call["args"]["emergency_contact"]
78
-
79
- data["ID"]["name"]=patient_name
80
- data["ID"]["DOB"]=patient_DOB
81
- data["ID"]["gender"]=patient_gender
82
- data["ID"]["contact"]=patient_contact
83
- data["ID"]["emergency_contact"]=patient_emergency_contact
84
 
85
  response = "\n".join(data)
86
 
87
  elif tool_call["name"] == "symptom":
88
-
89
  # Each order item is just a string. This is where it assembled as "drink (modifiers, ...)".
90
- main_symptom = tool_call["args"]["main_symptom"]
91
- symptom_length = tool_call["args"]["length"]
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
- data["symptom"]["main_symptom"]=main_symptom
94
- data["symptom"]["symptom_length"]=symptom_length
 
 
 
 
95
  response = "\n".join(data)
96
 
97
  elif tool_call["name"] == "confirm_data":
@@ -126,7 +198,7 @@ def data_node(state: DataState) -> DataState:
126
 
127
  #order_text = "\n".join(order)
128
  print("Saving the data!")
129
- #print(order_text)
130
 
131
  # TODO(you!): Implement cafe.
132
  data_saved = True
 
1
+ import pprint
2
+
3
  from langchain_core.tools import tool
4
  from modules.data_class import DataState
5
  from langgraph.prebuilt import InjectedState
 
22
  """
23
 
24
  @tool
25
+ def symptom(main_symptom: str, symptom_length: str) -> str:
26
  """Collecting patient's main symptom assessment including:
27
  - Primary symptoms
28
  - Duration of the symptoms
 
31
  The updated data with the patient's symptom information added.
32
  """
33
 
34
+ @tool
35
+ def pain(pain_location: str, pain_side: str, pain_intensity: int, pain_description: str, start_time: str, radiation: bool, triggers: str, symptom: str) -> str:
36
+ """Collecting patient's pain status including:
37
+ - Pain location using body mapping (head, arms, hands, trunk, legs, feet)
38
+ - Pain side (left or right)
39
+ - Pain intensity (0-10 scale for each location)
40
+ - Pain characteristics and patterns
41
+ - Onset time
42
+ - Radiation patterns
43
+ - Triggering factors
44
+ - Associated symptoms
45
+
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:
53
+ - Existing medical conditions
54
+ - First occurrence date
55
+ - Surgical history with dates
56
+ - Current medications
57
+ - Allergies
58
+
59
+ Returns:
60
+ The updated data with the patient's medical history added.
61
+ """
62
+
63
+ @tool
64
+ def family_hist(family_history: str) -> str:
65
+ """Collecting patient's family history
66
+
67
+ Returns:
68
+ The updated data with the patient's family history added.
69
+ """
70
+
71
+ @tool
72
+ def social_hist(occupation: str, smoking: bool, alcohol: bool, drug: bool, support_system: str, living_condition: str) -> str:
73
+ """Collecting patient's social history including:
74
+ - Occupation
75
+ - smoking or not
76
+ - alcohol use or not
77
+ - drug use or not
78
+ - living conditions
79
+ - support system
80
+
81
+ Returns:
82
+ The updated data with the patient's social history added.
83
+ """
84
+
85
+ @tool
86
+ def review_system(weight_change: str, fever: bool, chill: bool, night_sweats: bool, sleep: str, gastrointestinal: str, urinary: str) -> str:
87
+ """Collecting patient's review information including:
88
+ - Recent weight changes
89
+ - Constitutional symptoms (fever, chills, night sweats)
90
+ - Sleep patterns
91
+ - Gastrointestinal and urinary function
92
+
93
+ Returns:
94
+ The updated data with the patient's review.
95
+ """
96
 
97
  @tool
98
  def confirm_data() -> str:
 
132
  for tool_call in tool_msg.tool_calls:
133
 
134
  if tool_call["name"] == "patient_id":
 
135
  # Each order item is just a string. This is where it assembled as "drink (modifiers, ...)".
136
+ data["ID"]["name"]=tool_call["args"]["name"]
137
+ data["ID"]["DOB"]=tool_call["args"]["DOB"]
138
+ data["ID"]["gender"]=tool_call["args"]["gender"]
139
+ data["ID"]["contact"]=tool_call["args"]["contact"]
140
+ data["ID"]["emergency_contact"]=tool_call["args"]["emergency_contact"]
 
 
 
 
 
 
141
 
142
  response = "\n".join(data)
143
 
144
  elif tool_call["name"] == "symptom":
 
145
  # Each order item is just a string. This is where it assembled as "drink (modifiers, ...)".
146
+ data["symptom"]["main_symptom"]=tool_call["args"]["main_symptom"]
147
+ data["symptom"]["symptom_length"]=tool_call["args"]["length"]
148
+ response = "\n".join(data)
149
+
150
+ elif tool_call["name"] == "pain":
151
+ data["pain"]["pain_location"] = tool_call["args"]["pain_location"]
152
+ data["pain"]["pain_side"] = tool_call["args"]["pain_side"]
153
+ data["pain"]["pain_intensity"] = tool_call["args"]["pain_intensity"]
154
+ data["pain"]["pain_description"] = tool_call["args"]["pain_description"]
155
+ data["pain"]["start_time"] = tool_call["args"]["start_time"]
156
+ data["pain"]["radiation"] = tool_call["args"]["radiation"]
157
+ data["pain"]["triggers"] = tool_call["args"]["triggers"]
158
+ data["pain"]["symptom"] = tool_call["args"]["symptom"]
159
+ response = "\n".join(data)
160
 
161
+ elif tool_call["name"] == "medical_hist":
162
+ data["medical_hist"]["medical_condition"] = tool_call["args"]["medical_condition"]
163
+ data["medical_hist"]["first_time"] = tool_call["args"]["first_time"]
164
+ data["medical_hist"]["surgery_history"] = tool_call["args"]["surgery_history"]
165
+ data["medical_hist"]["medication"] = tool_call["args"]["medication"]
166
+ data["medical_hist"]["allergy"] = tool_call["args"]["allergy"]
167
  response = "\n".join(data)
168
 
169
  elif tool_call["name"] == "confirm_data":
 
198
 
199
  #order_text = "\n".join(order)
200
  print("Saving the data!")
201
+ pprint(data)
202
 
203
  # TODO(you!): Implement cafe.
204
  data_saved = True