Xiaosu Hu commited on
Commit
e4cc30b
·
1 Parent(s): ff06b17

update: some tests were not but not working

Browse files
modules/llm_in_use.py CHANGED
@@ -14,13 +14,14 @@ def get_llm():
14
  # llm = ChatOpenAI(temperature=0)
15
 
16
  # llm = ChatOllama(model="llama3.2:3b", temperature=0, base_url="http://141.211.127.171")
17
- # llm = ChatOllama(model="qwen2.5:14b", temperature=0, base_url="http://141.211.127.171")
18
  # llm = ChatOllama(model="nexusraven:13b", temperature=0, base_url="http://141.211.127.171")
19
 
20
  """llm = ChatOpenAI(
21
  api_key="ollama",
22
- model="llama3.2:latest",
23
  base_url="http://141.211.127.171/",
 
24
  )"""
25
 
26
 
 
14
  # llm = ChatOpenAI(temperature=0)
15
 
16
  # llm = ChatOllama(model="llama3.2:3b", temperature=0, base_url="http://141.211.127.171")
17
+ llm = ChatOllama(model="qwen2.5:14b", temperature=0, base_url="http://141.211.127.171")
18
  # llm = ChatOllama(model="nexusraven:13b", temperature=0, base_url="http://141.211.127.171")
19
 
20
  """llm = ChatOpenAI(
21
  api_key="ollama",
22
+ model="qwen2.5:14b",
23
  base_url="http://141.211.127.171/",
24
+ temperature=0
25
  )"""
26
 
27
 
paintrek-chat-v2.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": null,
6
  "metadata": {
7
  "execution": {
8
  "iopub.execute_input": "2025-01-29T20:09:11.440091Z",
@@ -36,7 +36,7 @@
36
  },
37
  {
38
  "cell_type": "code",
39
- "execution_count": null,
40
  "metadata": {
41
  "execution": {
42
  "iopub.execute_input": "2025-01-29T20:09:11.906458Z",
@@ -69,12 +69,12 @@
69
  "graph_builder.add_edge(START, \"chatbot_healthassistant\")\n",
70
  "graph_with_order_tools = graph_builder.compile(checkpointer=memory)\n",
71
  "\n",
72
- "Image(graph_with_order_tools.get_graph().draw_mermaid_png())"
73
  ]
74
  },
75
  {
76
  "cell_type": "code",
77
- "execution_count": null,
78
  "metadata": {
79
  "execution": {
80
  "iopub.execute_input": "2025-01-29T20:09:38.185616Z",
@@ -86,7 +86,32 @@
86
  "id": "NCRSgaBUfIHF",
87
  "trusted": true
88
  },
89
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  "source": [
91
  "# This is for the checkpointer to have a thread id to remember for each user, and I don't know if letter mix with number will work here \n",
92
  "# The default recursion limit for traversing nodes is 25 - setting it higher means you can try a more complex order with multiple steps and round-trips.\n",
 
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",
 
36
  },
37
  {
38
  "cell_type": "code",
39
+ "execution_count": 2,
40
  "metadata": {
41
  "execution": {
42
  "iopub.execute_input": "2025-01-29T20:09:11.906458Z",
 
69
  "graph_builder.add_edge(START, \"chatbot_healthassistant\")\n",
70
  "graph_with_order_tools = graph_builder.compile(checkpointer=memory)\n",
71
  "\n",
72
+ "# Image(graph_with_order_tools.get_graph().draw_mermaid_png())"
73
  ]
74
  },
75
  {
76
  "cell_type": "code",
77
+ "execution_count": 3,
78
  "metadata": {
79
  "execution": {
80
  "iopub.execute_input": "2025-01-29T20:09:38.185616Z",
 
86
  "id": "NCRSgaBUfIHF",
87
  "trusted": true
88
  },
89
+ "outputs": [
90
+ {
91
+ "name": "stdout",
92
+ "output_type": "stream",
93
+ "text": [
94
+ "Executing the chatbot graph...\n",
95
+ "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",
96
+ "User: Let's start\n",
97
+ "Model: Great! Let’s begin by gathering some basic information. Could you please provide your full name, date of birth, and contact number? This will help us proceed with the medical record setup.\n",
98
+ "User: My name is Frank my DOB is 19860214, my contact number is 123456\n",
99
+ "Model: Thank you for providing your information, Frank. Could you please confirm your full date of birth and provide any additional contact details such as an email address or another phone number? Also, could you tell me about your emergency contacts if applicable?\n",
100
+ "If you're ready to proceed with the rest of the intake process now, let me know!\n",
101
+ "User: my date of birth is Feb 14 1986, emergency contact is Zoe and her phone number is 568790\n",
102
+ "Your input data:\n",
103
+ "{'ID': {'name': '', 'DOB': datetime.date(1900, 1, 1), 'gender': '', 'contact': '', 'emergency_contact': ''}, 'symptom': {'main_symptom': '', 'symptom_length': ''}, 'pain': {'pain_location': '', 'pain_side': '', 'pain_intensity': 0, 'pain_description': '', 'start_time': datetime.date(1900, 1, 1), 'radiation': False, 'triggers': '', 'symptom': ''}, 'medical_hist': {'medical_condition': '', 'first_time': datetime.date(1900, 1, 1), 'surgery_history': '', 'medication': '', 'allergy': ''}, 'family_hist': {'family_history': ''}, 'social_hist': {'occupation': '', 'smoke': False, 'alcohol': False, 'drug': False, 'support_system': '', 'living_condition': ''}, 'review_system': {'weight_change': '', 'fever': False, 'chill': False, 'night_sweats': False, 'sleep': '', 'gastrointestinal': '', 'urinary': ''}, 'pain_manage': {'pain_medication': '', 'specialist': False, 'other_therapy': '', 'effectiveness': False}, 'functional': {'life_quality': '', 'limit_activity': '', 'mood': ''}, 'plan': {'goal': '', 'expectation': '', 'alternative_treatment': ''}}\n",
104
+ "Model: Let's start by gathering your personal information and medical history. Could you please provide me with the following details:\n",
105
+ "\n",
106
+ "1. Your full name, date of birth, and contact information.\n",
107
+ "2. The reason for your visit today (symptoms or concerns).\n",
108
+ "3. Any current pain issues you are experiencing.\n",
109
+ "\n",
110
+ "Once I have this initial information, we can proceed to gather more detailed medical history and other relevant data. Please start with the first two points if possible. For the third point, could you describe any areas where you're feeling pain, how long it has been going on, and what makes it better or worse?\n",
111
+ "User: q\n"
112
+ ]
113
+ }
114
+ ],
115
  "source": [
116
  "# This is for the checkpointer to have a thread id to remember for each user, and I don't know if letter mix with number will work here \n",
117
  "# The default recursion limit for traversing nodes is 25 - setting it higher means you can try a more complex order with multiple steps and round-trips.\n",
test_ollama.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 7,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -12,7 +12,7 @@
12
  },
13
  {
14
  "cell_type": "code",
15
- "execution_count": 2,
16
  "metadata": {},
17
  "outputs": [],
18
  "source": [
@@ -21,20 +21,9 @@
21
  },
22
  {
23
  "cell_type": "code",
24
- "execution_count": 3,
25
  "metadata": {},
26
- "outputs": [
27
- {
28
- "data": {
29
- "text/plain": [
30
- "AIMessage(content='Je aime le programmation.', additional_kwargs={}, response_metadata={'model': 'llama3.2:3b', 'created_at': '2025-03-03T20:22:10.986078Z', 'done': True, 'done_reason': 'stop', 'total_duration': 564767250, 'load_duration': 36439292, 'prompt_eval_count': 45, 'prompt_eval_duration': 207000000, 'eval_count': 7, 'eval_duration': 45000000, 'message': Message(role='assistant', content='', images=None, tool_calls=None)}, id='run-b473d2e4-5ea8-49c1-880c-57529bab3be3-0', usage_metadata={'input_tokens': 45, 'output_tokens': 7, 'total_tokens': 52})"
31
- ]
32
- },
33
- "execution_count": 3,
34
- "metadata": {},
35
- "output_type": "execute_result"
36
- }
37
- ],
38
  "source": [
39
  "from langchain_core.messages import AIMessage\n",
40
  "\n",
@@ -51,20 +40,9 @@
51
  },
52
  {
53
  "cell_type": "code",
54
- "execution_count": 4,
55
  "metadata": {},
56
- "outputs": [
57
- {
58
- "data": {
59
- "text/plain": [
60
- "AIMessage(content='Ich liebe Programmierung.', additional_kwargs={}, response_metadata={'model': 'llama3.2:3b', 'created_at': '2025-03-03T20:27:19.219749Z', 'done': True, 'done_reason': 'stop', 'total_duration': 1047082250, 'load_duration': 580482958, 'prompt_eval_count': 40, 'prompt_eval_duration': 161000000, 'eval_count': 6, 'eval_duration': 38000000, 'message': Message(role='assistant', content='', images=None, tool_calls=None)}, id='run-bbaf365e-81ba-4928-b6a3-8578efe20cc5-0', usage_metadata={'input_tokens': 40, 'output_tokens': 6, 'total_tokens': 46})"
61
- ]
62
- },
63
- "execution_count": 4,
64
- "metadata": {},
65
- "output_type": "execute_result"
66
- }
67
- ],
68
  "source": [
69
  "from langchain_core.prompts import ChatPromptTemplate\n",
70
  "\n",
@@ -90,24 +68,9 @@
90
  },
91
  {
92
  "cell_type": "code",
93
- "execution_count": 8,
94
  "metadata": {},
95
- "outputs": [
96
- {
97
- "data": {
98
- "text/plain": [
99
- "[{'name': 'validate_user',\n",
100
- " 'args': {'addresses': ['123 Fake St', '234 Pretend Boulevard'],\n",
101
- " 'user_id': 123},\n",
102
- " 'id': '0401ef59-16fb-446c-8fa2-11c2ad671d44',\n",
103
- " 'type': 'tool_call'}]"
104
- ]
105
- },
106
- "execution_count": 8,
107
- "metadata": {},
108
- "output_type": "execute_result"
109
- }
110
- ],
111
  "source": [
112
  "from typing import List\n",
113
  "\n",
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": null,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
12
  },
13
  {
14
  "cell_type": "code",
15
+ "execution_count": null,
16
  "metadata": {},
17
  "outputs": [],
18
  "source": [
 
21
  },
22
  {
23
  "cell_type": "code",
24
+ "execution_count": null,
25
  "metadata": {},
26
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
27
  "source": [
28
  "from langchain_core.messages import AIMessage\n",
29
  "\n",
 
40
  },
41
  {
42
  "cell_type": "code",
43
+ "execution_count": null,
44
  "metadata": {},
45
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
46
  "source": [
47
  "from langchain_core.prompts import ChatPromptTemplate\n",
48
  "\n",
 
68
  },
69
  {
70
  "cell_type": "code",
71
+ "execution_count": null,
72
  "metadata": {},
73
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  "source": [
75
  "from typing import List\n",
76
  "\n",