xiaosuhu1986 commited on
Commit
0126af1
·
1 Parent(s): 11df046

update: ollama model test

Browse files
Files changed (2) hide show
  1. modules/llm_in_use.py +3 -8
  2. paintrek-chat-v2.ipynb +62 -89
modules/llm_in_use.py CHANGED
@@ -7,19 +7,14 @@ from langchain_ollama import ChatOllama
7
  def get_llm():
8
  # Load environment variables from .env file
9
  load_dotenv()
 
10
  # Get the API key
11
  # google_api_key = os.getenv("GOOGLE_API_KEY")
12
 
13
  # llm = ChatOpenAI(temperature=0)
14
 
15
- # llm = ChatOllama(model="llama3.2:latest", temperature=0)
16
-
17
- """llm = ChatOpenAI(
18
- api_key="ollama",
19
- model="llama3.2:latest",
20
- base_url="http://141.211.127.171/",
21
- )"""
22
 
23
- llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash-latest")
24
 
25
  return llm
 
7
  def get_llm():
8
  # Load environment variables from .env file
9
  load_dotenv()
10
+
11
  # Get the API key
12
  # google_api_key = os.getenv("GOOGLE_API_KEY")
13
 
14
  # llm = ChatOpenAI(temperature=0)
15
 
16
+ llm = ChatOllama(model="llama3.2:latest", temperature=0, base_url="http://141.211.127.171")
 
 
 
 
 
 
17
 
18
+ # llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash-latest")
19
 
20
  return llm
paintrek-chat-v2.ipynb CHANGED
@@ -14,7 +14,16 @@
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",
@@ -105,33 +114,55 @@
105
  "text": [
106
  "Executing the chatbot graph...\n",
107
  "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",
108
- "User: Let's start\n",
109
- "Model: First, let's collect some basic information for identification. What is your full name, date of birth (YYYY-MM-DD), gender, and contact number?\n",
110
- "User: I am Frank, DOB 1986-01-01, male, phone number is 12345, emergency name is Zoe, number is 67890.\n",
111
- "Model: Thank you. Now, can you describe your main symptom and how long you've been experiencing it?\n",
112
- "User: I had a headache, and it started two days ago.\n",
113
- "Model: Okay. Let's move on to your pain. Can you tell me about the location, side (left, right, or both), and intensity (on a scale of 0-10, with 0 being no pain and 10 being the worst pain imaginable) of your headache? Also, please describe the characteristics of your pain (e.g., sharp, dull, throbbing), when it started, if it radiates to other areas, what triggers it, and if there are any associated symptoms.\n",
114
- "User: 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. \n",
115
- "Model: To continue, could you provide information on your medical history, including any existing medical conditions, when they first appeared, any surgeries you've had and when, your current medications, and any allergies you have?\n",
116
- "User: I had sinus, diagnosed in 2001-01-01, I did not have any surgery. I am taking ibprofin, no allergies.\n",
117
- "Model: Thank you. Now, let's discuss your family history. Are there any significant medical conditions that run in your family?\n",
118
- "User: My mom had a lung cancer at 45.\n",
119
- "Model: Could you share some information about your social history, including your occupation, whether you smoke or drink alcohol, your living situation, and your support system?\n",
120
- "User: I am a data scientist, I am a viggie. I don't use tobbaco or alcohol. My stress level is midium. \n",
121
- "Model: Let's proceed with a systems review. Have you experienced any recent weight changes, fever, chills, night sweats, changes in sleep patterns, gastrointestinal issues, or urinary problems?\n",
122
- "User: I sleep well, and no other symptoms.\n",
123
- "Model: Now, let's discuss your pain management history. What pain medications are you currently using, have you consulted any specialists for your pain, have you tried any alternative therapies, and how effective have these treatments been?\n",
124
- "User: No, I am not taking any other medication, and I haven't tried any alternative therapies. \n",
125
- "Model: Finally, let's assess your functional status. How has this pain affected your quality of life, what activities have you been limited in, and how would you describe your current mood and emotional state?\n",
126
- "User: I am okay on my mood, and my quality of life is also good. I want to fix my headache.\n",
127
- "Model: Before we conclude, could you please confirm that all the information I have gathered is accurate? If there are any corrections or additions, please let me know now.\n",
128
- "User: Can you print the data you have already collected?\n",
129
- "Model: Okay, everything seems correct.\n",
130
  "User: \n",
131
- "Your input data:\n",
132
- "{'ID': {'name': 'Frank', 'DOB': '1986-01-01', 'gender': 'male', 'contact': '12345', 'emergency_contact': '67890'}, 'symptom': {'main_symptom': 'headache', 'symptom_length': 'two days'}, 'pain': {'pain_location': 'right head', 'pain_side': 'right', 'pain_intensity': 2.0, 'pain_description': 'sharp', 'start_time': '2 days ago', 'radiation': False, 'triggers': 'cold', 'symptom': 'headache'}, 'medical_hist': {'medical_condition': 'sinus', 'first_time': '2001-01-01', 'surgery_history': 'None', 'medication': 'ibprofin', 'allergy': 'None'}, 'family_hist': {'family_history': 'Mother had lung cancer at 45'}, 'social_hist': {'occupation': 'data scientist', 'smoke': False, 'alcohol': False, 'drug': False, 'support_system': 'unknown', 'living_condition': 'medium stress'}, 'review_system': {'weight_change': 'None', 'fever': False, 'chill': False, 'night_sweats': False, 'sleep': 'well', 'gastrointestinal': 'None', 'urinary': 'None'}, 'pain_manage': {'pain_medication': 'None', 'specialist': False, 'other_therapy': 'None', 'effectiveness': False}, 'functional': {'life_quality': 'good', 'limit_activity': 'None', 'mood': 'okay'}, 'plan': {'goal': '', 'expectation': '', 'alternative_treatment': ''}}\n",
133
- "Saving the data!\n",
134
- "{'ID': {'name': 'Frank', 'DOB': '1986-01-01', 'gender': 'male', 'contact': '12345', 'emergency_contact': '67890'}, 'symptom': {'main_symptom': 'headache', 'symptom_length': 'two days'}, 'pain': {'pain_location': 'right head', 'pain_side': 'right', 'pain_intensity': 2.0, 'pain_description': 'sharp', 'start_time': '2 days ago', 'radiation': False, 'triggers': 'cold', 'symptom': 'headache'}, 'medical_hist': {'medical_condition': 'sinus', 'first_time': '2001-01-01', 'surgery_history': 'None', 'medication': 'ibprofin', 'allergy': 'None'}, 'family_hist': {'family_history': 'Mother had lung cancer at 45'}, 'social_hist': {'occupation': 'data scientist', 'smoke': False, 'alcohol': False, 'drug': False, 'support_system': 'unknown', 'living_condition': 'medium stress'}, 'review_system': {'weight_change': 'None', 'fever': False, 'chill': False, 'night_sweats': False, 'sleep': 'well', 'gastrointestinal': 'None', 'urinary': 'None'}, 'pain_manage': {'pain_medication': 'None', 'specialist': False, 'other_therapy': 'None', 'effectiveness': False}, 'functional': {'life_quality': 'good', 'limit_activity': 'None', 'mood': 'okay'}, 'plan': {'goal': '', 'expectation': '', 'alternative_treatment': ''}}\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  ]
136
  }
137
  ],
@@ -155,72 +186,14 @@
155
  },
156
  {
157
  "cell_type": "code",
158
- "execution_count": 4,
159
  "metadata": {
160
  "trusted": true
161
  },
162
- "outputs": [
163
- {
164
- "data": {
165
- "text/plain": [
166
- "{'ID': {'name': 'Frank',\n",
167
- " 'DOB': '1986-01-01',\n",
168
- " 'gender': 'male',\n",
169
- " 'contact': '12345',\n",
170
- " 'emergency_contact': '67890'},\n",
171
- " 'symptom': {'main_symptom': 'headache', 'symptom_length': 'two days'},\n",
172
- " 'pain': {'pain_location': 'right head',\n",
173
- " 'pain_side': 'right',\n",
174
- " 'pain_intensity': 2.0,\n",
175
- " 'pain_description': 'sharp',\n",
176
- " 'start_time': '2 days ago',\n",
177
- " 'radiation': False,\n",
178
- " 'triggers': 'cold',\n",
179
- " 'symptom': 'headache'},\n",
180
- " 'medical_hist': {'medical_condition': 'sinus',\n",
181
- " 'first_time': '2001-01-01',\n",
182
- " 'surgery_history': 'None',\n",
183
- " 'medication': 'ibprofin',\n",
184
- " 'allergy': 'None'},\n",
185
- " 'family_hist': {'family_history': 'Mother had lung cancer at 45'},\n",
186
- " 'social_hist': {'occupation': 'data scientist',\n",
187
- " 'smoke': False,\n",
188
- " 'alcohol': False,\n",
189
- " 'drug': False,\n",
190
- " 'support_system': 'unknown',\n",
191
- " 'living_condition': 'medium stress'},\n",
192
- " 'review_system': {'weight_change': 'None',\n",
193
- " 'fever': False,\n",
194
- " 'chill': False,\n",
195
- " 'night_sweats': False,\n",
196
- " 'sleep': 'well',\n",
197
- " 'gastrointestinal': 'None',\n",
198
- " 'urinary': 'None'},\n",
199
- " 'pain_manage': {'pain_medication': 'None',\n",
200
- " 'specialist': False,\n",
201
- " 'other_therapy': 'None',\n",
202
- " 'effectiveness': False},\n",
203
- " 'functional': {'life_quality': 'good',\n",
204
- " 'limit_activity': 'None',\n",
205
- " 'mood': 'okay'},\n",
206
- " 'plan': {'goal': '', 'expectation': '', 'alternative_treatment': ''}}"
207
- ]
208
- },
209
- "execution_count": 4,
210
- "metadata": {},
211
- "output_type": "execute_result"
212
- }
213
- ],
214
  "source": [
215
  "state[\"data\"]"
216
  ]
217
- },
218
- {
219
- "cell_type": "code",
220
- "execution_count": null,
221
- "metadata": {},
222
- "outputs": [],
223
- "source": []
224
  }
225
  ],
226
  "metadata": {
@@ -238,7 +211,7 @@
238
  "sourceType": "notebook"
239
  },
240
  "kernelspec": {
241
- "display_name": "paintrek",
242
  "language": "python",
243
  "name": "python3"
244
  },
@@ -252,7 +225,7 @@
252
  "name": "python",
253
  "nbconvert_exporter": "python",
254
  "pygments_lexer": "ipython3",
255
- "version": "3.10.13"
256
  }
257
  },
258
  "nbformat": 4,
 
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",
 
114
  "text": [
115
  "Executing the chatbot graph...\n",
116
  "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",
117
+ "User: Hello\n",
118
+ "Model: I'm MedAssist, your intelligent medical intake system. I'll guide you through a structured data collection process to gather comprehensive patient information.\n",
119
+ "\n",
120
+ "To begin, can you please tell me your name and date of birth? This will help me identify you in our records and ensure accurate communication throughout the process.\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  "User: \n",
122
+ "Model: Here is the JSON payload that can be sent to the server to collect all the necessary information:\n",
123
+ "\n",
124
+ "```json\n",
125
+ "{\n",
126
+ " \"name\": \"\",\n",
127
+ " \"family_hist\": \"\",\n",
128
+ " \"social_hist\": {\n",
129
+ " \"occupation\": \"\",\n",
130
+ " \"smoke\": false,\n",
131
+ " \"alcohol\": false,\n",
132
+ " \"drug\": false,\n",
133
+ " \"support_system\": \"\",\n",
134
+ " \"living_condition\": \"\"\n",
135
+ " },\n",
136
+ " \"pain_manage\": {\n",
137
+ " \"pain_medication\": \"\",\n",
138
+ " \"specialist\": false,\n",
139
+ " \"other_therapy\": \"\",\n",
140
+ " \"effectiveness\": false\n",
141
+ " },\n",
142
+ " \"functional\": {\n",
143
+ " \"life_quality\": \"\",\n",
144
+ " \"limit_activity\": \"\",\n",
145
+ " \"mood\": \"\"\n",
146
+ " },\n",
147
+ " \"plan\": {\n",
148
+ " \"goal\": \"\",\n",
149
+ " \"expectation\": \"\",\n",
150
+ " \"alternative_treatment\": \"\"\n",
151
+ " },\n",
152
+ " \"review_system\": {\n",
153
+ " \"weight_change\": \"\",\n",
154
+ " \"fever\": false,\n",
155
+ " \"chill\": false,\n",
156
+ " \"night_sweats\": false,\n",
157
+ " \"sleep\": \"\",\n",
158
+ " \"gastrointestinal\": \"\",\n",
159
+ " \"urinary\": \"\"\n",
160
+ " }\n",
161
+ "}\n",
162
+ "```\n",
163
+ "\n",
164
+ "This payload includes all the necessary fields to collect information about the patient's family history, social history, pain management, functional assessment, and review system. Note that some of these fields are optional (e.g., `smoke`, `alcohol`, etc.) and can be set to `false` if not applicable.\n",
165
+ "User: q\n"
166
  ]
167
  }
168
  ],
 
186
  },
187
  {
188
  "cell_type": "code",
189
+ "execution_count": null,
190
  "metadata": {
191
  "trusted": true
192
  },
193
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  "source": [
195
  "state[\"data\"]"
196
  ]
 
 
 
 
 
 
 
197
  }
198
  ],
199
  "metadata": {
 
211
  "sourceType": "notebook"
212
  },
213
  "kernelspec": {
214
+ "display_name": "paintrekbot",
215
  "language": "python",
216
  "name": "python3"
217
  },
 
225
  "name": "python",
226
  "nbconvert_exporter": "python",
227
  "pygments_lexer": "ipython3",
228
+ "version": "3.12.8"
229
  }
230
  },
231
  "nbformat": 4,