Upload medical_chatbot.py with huggingface_hub
Browse files- medical_chatbot.py +336 -0
medical_chatbot.py
ADDED
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น๋ฅผ ์ํ ์
|
2 |
+
# !pip install transformers torch pandas openpyxl
|
3 |
+
|
4 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
+
import torch
|
6 |
+
import pandas as pd
|
7 |
+
from datetime import datetime
|
8 |
+
|
9 |
+
class SimplifiedMedicalChatbot:
|
10 |
+
def __init__(self, data_path="/content/sample_data/sick.xlsx"):
|
11 |
+
self.load_database(data_path)
|
12 |
+
self.disclaimer = """
|
13 |
+
์ฃผ์: ์ด ์ฑ๋ด์ ์ฐธ๊ณ ์ฉ์ผ๋ก๋ง ์ฌ์ฉํ์๊ธฐ ๋ฐ๋๋๋ค.
|
14 |
+
์ ํํ ์ง๋จ์ ์ํด์๋ ๋ฐ๋์ ์๋ฃ ์ ๋ฌธ๊ฐ์ ์๋ดํ์ธ์.
|
15 |
+
์ฆ์์ด ์ฌ๊ฐํ๋ค๊ณ ํ๋จ๋๋ฉด ์ฆ์ ๋ณ์์ ๋ฐฉ๋ฌธํ์๊ธฐ ๋ฐ๋๋๋ค.
|
16 |
+
"""
|
17 |
+
|
18 |
+
def load_database(self, data_path):
|
19 |
+
try:
|
20 |
+
self.df = pd.read_excel(data_path)
|
21 |
+
self.df = self.df.fillna('')
|
22 |
+
print(f"๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ก๋ ์๋ฃ: {len(self.df)} ๊ฐ์ ๋ ์ฝ๋")
|
23 |
+
except Exception as e:
|
24 |
+
print(f"๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ก๋ฉ ์คํจ: {str(e)}")
|
25 |
+
self.df = pd.DataFrame()
|
26 |
+
|
27 |
+
def calculate_age(self, born_year):
|
28 |
+
"""์ถ์์ฐ๋๋ก ๋์ด ๊ณ์ฐ"""
|
29 |
+
current_year = datetime.now().year
|
30 |
+
return current_year - int(born_year)
|
31 |
+
|
32 |
+
def get_age_group(self, age):
|
33 |
+
if age < 12:
|
34 |
+
return "์ด๋ฆฐ์ด"
|
35 |
+
elif age >= 65:
|
36 |
+
return "๋
ธ์ธ"
|
37 |
+
else:
|
38 |
+
return "์ฑ์ธ"
|
39 |
+
|
40 |
+
def simple_symptom_matching(self, pain, description):
|
41 |
+
"""์ฆ์ ๋งค์นญ ๋ก์ง - pain๊ณผ description ํ์ฉ, ์ ๋ขฐ๋ ์ ์ ๊ณ์ฐ"""
|
42 |
+
if '์ฆ์' not in self.df.columns:
|
43 |
+
print("์ฆ์ ์ปฌ๋ผ์ด ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์์ต๋๋ค.")
|
44 |
+
return []
|
45 |
+
|
46 |
+
matched_diseases = []
|
47 |
+
symptoms = f"{pain} {description}".strip().split()
|
48 |
+
|
49 |
+
for _, row in self.df.iterrows():
|
50 |
+
db_symptoms = row['์ฆ์'].split()
|
51 |
+
|
52 |
+
# ๊ฐ ์ฆ์๋ณ ์ ์ ๊ณ์ฐ
|
53 |
+
score = 0
|
54 |
+
|
55 |
+
# ์ฃผ์ ์ฆ์(pain) ์ฒดํฌ
|
56 |
+
if pain.strip() and pain in row['์ฆ์']:
|
57 |
+
score += 60 # ์ฃผ์ ์ฆ์ ์ผ์น์ ๊ธฐ๋ณธ 60์
|
58 |
+
|
59 |
+
# ์์ธ ์ฆ์ ์ฒดํฌ
|
60 |
+
desc_symptoms = description.strip().split() if description else []
|
61 |
+
for symptom in desc_symptoms:
|
62 |
+
if symptom in row['์ฆ์']:
|
63 |
+
score += 20 # ๊ฐ ๋ถ๊ฐ ์ฆ์ ์ผ์น์ 20์ ์ถ๊ฐ
|
64 |
+
|
65 |
+
# ์ต์ํ์ ๊ด๋ จ์ฑ์ด ์๋ ๊ฒฝ์ฐ ์ถ๊ฐ (0์ ์ด์)
|
66 |
+
if score > 0 or pain in row['์ฆ์']:
|
67 |
+
matched_diseases.append((row['์งํ๋ช
'], score))
|
68 |
+
|
69 |
+
# ๊ฒฐ๊ณผ๊ฐ 3๊ฐ ๋ฏธ๋ง์ธ ๊ฒฝ์ฐ ๊ด๋ จ ์ง๋ณ ์ถ๊ฐ
|
70 |
+
sorted_diseases = sorted(matched_diseases, key=lambda x: x[1], reverse=True)
|
71 |
+
|
72 |
+
if len(sorted_diseases) < 3:
|
73 |
+
# ์ ์์ ๊ด๊ณ์์ด ์ฃผ์ ์ฆ์์ด ํฌํจ๋ ๋ค๋ฅธ ์ง๋ณ๋ค๋ ์ถ๊ฐ
|
74 |
+
for _, row in self.df.iterrows():
|
75 |
+
disease_name = row['์งํ๋ช
']
|
76 |
+
if disease_name not in [d[0] for d in sorted_diseases]:
|
77 |
+
if pain in row['์ฆ์']:
|
78 |
+
sorted_diseases.append((disease_name, 10)) # ๋ฎ์ ์ ์๋ก ์ถ๊ฐ
|
79 |
+
if len(sorted_diseases) >= 3:
|
80 |
+
break
|
81 |
+
|
82 |
+
# ์์ 3๊ฐ ๋ฐํ (3๊ฐ ๋ฏธ๋ง์ธ ๊ฒฝ์ฐ ์ ์ฒด ๋ฐํ)
|
83 |
+
return sorted_diseases[:3]
|
84 |
+
|
85 |
+
def get_medicine_info(self, disease, age_group, medi_tf=False):
|
86 |
+
"""์ง๋ณ๊ณผ ๋์ด๋์ ๋ฐ๋ฅธ ์ฝํ ์ ๋ณด ๋ฐํ"""
|
87 |
+
try:
|
88 |
+
disease_info = self.df[self.df['์งํ๋ช
'] == disease]
|
89 |
+
|
90 |
+
if disease_info.empty:
|
91 |
+
return {
|
92 |
+
"ageWarning": "",
|
93 |
+
"medicine": "",
|
94 |
+
"ingredients": "",
|
95 |
+
"medicalAttention": [],
|
96 |
+
"error": "ํด๋น ์ง๋ณ์ ๋ํ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค."
|
97 |
+
}
|
98 |
+
|
99 |
+
result = {
|
100 |
+
"ageWarning": "",
|
101 |
+
"medicine": "",
|
102 |
+
"ingredients": "",
|
103 |
+
"medicalAttention": []
|
104 |
+
}
|
105 |
+
|
106 |
+
# ๋์ด๋๋ณ ์ฃผ์์ฌํญ
|
107 |
+
age_specific_info = disease_info['๋์ด๋ '].iloc[0]
|
108 |
+
if age_specific_info:
|
109 |
+
if age_group == "์ด๋ฆฐ์ด":
|
110 |
+
result["ageWarning"] = f"์ด๋ฆฐ์ด(12์ธ ๋ฏธ๋ง) ์ฃผ์์ฌํญ: {age_specific_info}"
|
111 |
+
elif age_group == "๋
ธ์ธ":
|
112 |
+
result["ageWarning"] = f"๋
ธ์ธ(65์ธ ์ด์) ์ฃผ์์ฌํญ: {age_specific_info}"
|
113 |
+
|
114 |
+
# mediTF๊ฐ true์ผ ๋๋ง ์ฝํ ์ ๋ณด ํฌํจ
|
115 |
+
if medi_tf:
|
116 |
+
if disease_info['์ถ์ฒ ์์ฝํ'].iloc[0]:
|
117 |
+
result["medicine"] = disease_info['์ถ์ฒ ์์ฝํ'].iloc[0]
|
118 |
+
if disease_info['์ฑ๋ถ'].iloc[0]:
|
119 |
+
result["ingredients"] = disease_info['์ฑ๋ถ'].iloc[0]
|
120 |
+
|
121 |
+
# ์์ฌ ์ง๋ฃ ํ์ ์ฌํญ
|
122 |
+
medical_attention = disease_info['์์ฌ์ ์ง๋ฃ๊ฐ ํ์ํ ๊ฒฝ์ฐ'].iloc[0]
|
123 |
+
if medical_attention:
|
124 |
+
attention_list = [item.strip() for item in medical_attention.split('
|
125 |
+
')]
|
126 |
+
result["medicalAttention"] = attention_list
|
127 |
+
|
128 |
+
return result
|
129 |
+
|
130 |
+
except Exception as e:
|
131 |
+
print(f"์์ฝํ ์ ๋ณด ์กฐํ ์ค ์ค๋ฅ: {str(e)}")
|
132 |
+
return {
|
133 |
+
"ageWarning": "",
|
134 |
+
"medicine": "",
|
135 |
+
"ingredients": "",
|
136 |
+
"medicalAttention": [],
|
137 |
+
"error": f"์ ๋ณด ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
138 |
+
}
|
139 |
+
|
140 |
+
def format_chat_response(self, response_data):
|
141 |
+
"""JSON ์๋ต์ ์ฌ์ฉ์ ์นํ์ ์ธ ํ
์คํธ๋ก ๋ณํ"""
|
142 |
+
chat_response = []
|
143 |
+
|
144 |
+
# ์ฌ์ฉ์ ์ ๋ณด ์์ฝ
|
145 |
+
chat_response.append(f"\n[{response_data['ageGroup']}({response_data['age']}์ธ) / {response_data['sex']} ์ฌ์ฉ์ ๋ถ์ ๊ฒฐ๊ณผ]")
|
146 |
+
|
147 |
+
# ๋ถ์ ๊ฒฐ๊ณผ
|
148 |
+
for analysis in response_data['analysis']:
|
149 |
+
if analysis['disease']:
|
150 |
+
chat_response.append(f"\n## ์ถ์ ์งํ: {analysis['disease']}")
|
151 |
+
if analysis['ageWarning']:
|
152 |
+
chat_response.append(analysis['ageWarning'])
|
153 |
+
if analysis['medicine']:
|
154 |
+
chat_response.append(f"์ถ์ฒ ์์ฝํ: {analysis['medicine']}")
|
155 |
+
if analysis['ingredients']:
|
156 |
+
chat_response.append(f"์ฃผ์ ์ฑ๋ถ: {analysis['ingredients']}")
|
157 |
+
if analysis['medicalAttention']:
|
158 |
+
chat_response.append("์์ฌ์ ์ง๋ฃ๊ฐ ํ์ํ ๊ฒฝ์ฐ:")
|
159 |
+
chat_response.extend(analysis['medicalAttention'])
|
160 |
+
else:
|
161 |
+
chat_response.append("\n์ผ์นํ๋ ์ง๋ณ์ ์ฐพ์ ์ ์์ต๋๋ค.")
|
162 |
+
chat_response.append("-" * 40)
|
163 |
+
|
164 |
+
# ๋ฉด์ฑ
์กฐํญ
|
165 |
+
chat_response.append(f"\n{response_data['disclaimer']}")
|
166 |
+
|
167 |
+
return "\n".join(chat_response)
|
168 |
+
|
169 |
+
def process_request(self, request_data):
|
170 |
+
"""๋ฐฑ์๋ ์์ฒญ ์ฒ๋ฆฌ"""
|
171 |
+
try:
|
172 |
+
# ์ฌ์ฉ์ ์ ๋ณด ์ถ์ถ
|
173 |
+
user_id = request_data.get("userId", "")
|
174 |
+
born_year = request_data.get("bornYear", "")
|
175 |
+
sex = request_data.get("sex", "")
|
176 |
+
|
177 |
+
# ์ฆ์ ์ ๋ณด ์ถ์ถ
|
178 |
+
pain = request_data.get("pain", "")
|
179 |
+
pain_description = request_data.get("description", "")
|
180 |
+
medi_tf = request_data.get("mediTF", False)
|
181 |
+
|
182 |
+
# ๋์ด ๊ณ์ฐ
|
183 |
+
age = self.calculate_age(born_year)
|
184 |
+
age_group = self.get_age_group(age)
|
185 |
+
|
186 |
+
# ์ฆ์ ๋งค์นญ
|
187 |
+
matched_diseases = self.simple_symptom_matching(pain, pain_description)
|
188 |
+
|
189 |
+
# ์๋ต ์์ฑ
|
190 |
+
response = {
|
191 |
+
"userId": user_id,
|
192 |
+
"age": age,
|
193 |
+
"ageGroup": age_group,
|
194 |
+
"sex": sex,
|
195 |
+
"analysis": []
|
196 |
+
}
|
197 |
+
|
198 |
+
if matched_diseases:
|
199 |
+
response["analysis"] = []
|
200 |
+
for disease, _ in matched_diseases:
|
201 |
+
medical_info = self.get_medicine_info(disease, age_group, medi_tf)
|
202 |
+
disease_info = {
|
203 |
+
"disease": disease,
|
204 |
+
"ageWarning": medical_info["ageWarning"],
|
205 |
+
"medicine": medical_info["medicine"],
|
206 |
+
"ingredients": medical_info["ingredients"],
|
207 |
+
"medicalAttention": medical_info["medicalAttention"]
|
208 |
+
}
|
209 |
+
response["analysis"].append(disease_info)
|
210 |
+
else:
|
211 |
+
response["analysis"].append({
|
212 |
+
"disease": None,
|
213 |
+
"confidence": 0.0, # ๋งค์นญ ์คํจ์ 0% ์ ๋ขฐ๋
|
214 |
+
"ageWarning": "",
|
215 |
+
"medicine": "",
|
216 |
+
"ingredients": "",
|
217 |
+
"medicalAttention": [],
|
218 |
+
"error": "์ผ์นํ๋ ์ง๋ณ์ ์ฐพ์ ์ ์์ต๋๋ค."
|
219 |
+
})
|
220 |
+
|
221 |
+
response["disclaimer"] = self.disclaimer
|
222 |
+
|
223 |
+
return {
|
224 |
+
"json_response": response,
|
225 |
+
"chat_message": self.format_chat_response(response)
|
226 |
+
}
|
227 |
+
|
228 |
+
except Exception as e:
|
229 |
+
error_response = {
|
230 |
+
"error": f"์์ฒญ ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}",
|
231 |
+
"disclaimer": self.disclaimer
|
232 |
+
}
|
233 |
+
return {
|
234 |
+
"json_response": error_response,
|
235 |
+
"chat_message": f"์ฃ์กํฉ๋๋ค. ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}\n\n{self.disclaimer}"
|
236 |
+
}
|
237 |
+
|
238 |
+
def create_sample_data():
|
239 |
+
"""ํ
์คํธ์ฉ ์ํ ๋ฐ์ดํฐ ์์ฑ"""
|
240 |
+
data = {
|
241 |
+
'์งํ๋ช
': ['ํธ๋ํต', '๊ตฐ๋ฐ์ฑ ๋ํต', '๊ธด์ฅ์ฑ ๋ํต', '๋์๋ง์ผ', '๊ฐ๊ธฐ', '์์ผ'],
|
242 |
+
'์ฆ์': [
|
243 |
+
'๋ํต ํ์ชฝ ๋จธ๋ฆฌ ํต์ฆ ๊ตฌํ ์ด์ง๋ฌ์ ๋ฉ์ค๊บผ์',
|
244 |
+
'ํ์ชฝ ๋จธ๋ฆฌ ํต์ฆ ๋ํต์ฆ ์ฝง๋ฌผ ์ด์ง๏ฟฝ๏ฟฝ์',
|
245 |
+
'๋ํต ๋ชฉํต์ฆ ์ด๊นจํต์ฆ ๋ฉ์ค๊บผ์ ์คํธ๋ ์ค',
|
246 |
+
'๋ํต ๊ตฌํ ๋ฐ์ด ๋ชฉ์ด ๋ปฃ๋ปฃํจ ๋ฉ์ค๊บผ์',
|
247 |
+
'๋ํต ๋ฐ์ด ๊ธฐ์นจ ์ฝง๋ฌผ',
|
248 |
+
'๋ณตํต ๋ฉ์ค๊บผ์ ๊ตฌํ ์ํ๋ถ๋'
|
249 |
+
],
|
250 |
+
'์ถ์ฒ ์์ฝํ': [
|
251 |
+
'๊ฒ๋ณด๋ฆฐ',
|
252 |
+
'ํ์ด๋ ๋',
|
253 |
+
'์ด์ง์6',
|
254 |
+
'ํญ์์ ์ฒ๋ฐฉ ํ์',
|
255 |
+
'ํ์ด๋ ๋',
|
256 |
+
'๊ฐ๋น์ค์ฝ'
|
257 |
+
],
|
258 |
+
'์ฑ๋ถ': [
|
259 |
+
'์ด๋ถํ๋กํ',
|
260 |
+
'์์ธํธ์๋ฏธ๋
ธํ',
|
261 |
+
'๋ํ๋ก์ผ',
|
262 |
+
'์ฒ๋ฐฉ์ฝ๋ง ๊ฐ๋ฅ',
|
263 |
+
'์์ธํธ์๋ฏธ๋
ธํ',
|
264 |
+
'์๊ธด์ฐ๋ํธ๋ฅจ'
|
265 |
+
],
|
266 |
+
'์์ฌ์ ์ง๋ฃ๊ฐ ํ์ํ ๊ฒฝ์ฐ': [
|
267 |
+
'๋ํต์ด 24์๊ฐ ์ด์ ์ง์๋ ๋\n์์ผ๊ฐ ํ๋ ค์ง ๋',
|
268 |
+
'ํต์ฆ์ด ๋งค์ฐ ์ฌํ ๋\nํ๋ฃจ ์ฌ๋ฌ๋ฒ ๋ฐ์ํ ๋',
|
269 |
+
'๋ํต์ด ๋ง์ฑ์ ์ผ ๋\n์ผ์์ํ์ด ์ด๋ ค์ธ ๋',
|
270 |
+
'์ฆ์ ๋ณ์ ๋ฐฉ๋ฌธ ํ์\n์๊ธ์ํฉ์ผ ์ ์์',
|
271 |
+
'๊ณ ์ด์ด 3์ผ ์ด์ ์ง์๋ ๋\nํธํก๊ณค๋์ด ์์ ๋',
|
272 |
+
'๋ณตํต์ด ์ฌํ๊ณ ์ง์๋ ๋\n์์ฅ ์ถํ ์ฆ์์ด ์์ ๋'
|
273 |
+
],
|
274 |
+
'๋์ด๋ ': [
|
275 |
+
'์งํต์ ๋ณต์ฉ๋ ์กฐ์ ํ์',
|
276 |
+
'๋
ธ์ธ ํฌ์ฝ ์ฃผ์',
|
277 |
+
'์ฒญ์๋
๋ณต์ฉ๋ ์กฐ์ ',
|
278 |
+
'์ฐ๋ น๋ณ ํญ์์ ์ฒ๋ฐฉ ํ์',
|
279 |
+
'ํด์ด์ ๋ณต์ฉ ์ ์ฃผ์',
|
280 |
+
'์์ฐ ๋ถ๋น ์กฐ์ ์ ์ฃผ์'
|
281 |
+
]
|
282 |
+
}
|
283 |
+
return pd.DataFrame(data)
|
284 |
+
|
285 |
+
def run_test():
|
286 |
+
"""ํ
์คํธ ์คํ"""
|
287 |
+
print("=== ์๋ฃ ์๋ด ์ฑ๋ด ํ
์คํธ ์์ ===")
|
288 |
+
|
289 |
+
# ์ํ ๋ฐ์ดํฐ ์์ฑ ๋ฐ ์์ ํ์ผ ์ ์ฅ
|
290 |
+
sample_df = create_sample_data()
|
291 |
+
temp_file = "/content/sample_data/sick.xlsx"
|
292 |
+
sample_df.to_excel(temp_file, index=False)
|
293 |
+
print("์ํ ๋ฐ์ดํฐ ์์ฑ ์๋ฃ")
|
294 |
+
|
295 |
+
# ์ฑ๋ด ์ธ์คํด์ค ์์ฑ
|
296 |
+
chatbot = SimplifiedMedicalChatbot(temp_file)
|
297 |
+
|
298 |
+
# ํ
์คํธ ์ผ์ด์ค๋ค
|
299 |
+
test_cases = [
|
300 |
+
{
|
301 |
+
"userId": "user1",
|
302 |
+
"bornYear": "1990",
|
303 |
+
"sex": "male",
|
304 |
+
"pain": "๋ํต",
|
305 |
+
"description": "ํ์ชฝ ๋จธ๋ฆฌ๊ฐ ์ํ๊ณ ๋ฉ์ค๊บผ์์",
|
306 |
+
"mediTF": True
|
307 |
+
},
|
308 |
+
{
|
309 |
+
"userId": "user2",
|
310 |
+
"bornYear": "2015",
|
311 |
+
"sex": "female",
|
312 |
+
"pain": "๋ณตํต",
|
313 |
+
"description": "๋ฐฐ๊ฐ ์ํ๊ณ ๊ตฌํ ๋ฅผ ํด์",
|
314 |
+
"mediTF": True
|
315 |
+
}
|
316 |
+
]
|
317 |
+
|
318 |
+
# ๊ฐ ํ
์คํธ ์ผ์ด์ค ์คํ
|
319 |
+
for i, test_case in enumerate(test_cases, 1):
|
320 |
+
print(f"\n=== ํ
์คํธ ์ผ์ด์ค {i} ===")
|
321 |
+
print("์
๋ ฅ:", test_case)
|
322 |
+
|
323 |
+
# ์์ฒญ ์ฒ๋ฆฌ
|
324 |
+
result = chatbot.process_request(test_case)
|
325 |
+
|
326 |
+
# ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
327 |
+
print("\n[์ฑ๋ด ์๋ต]")
|
328 |
+
print(result["chat_message"])
|
329 |
+
|
330 |
+
print("\n[JSON ์๋ต]")
|
331 |
+
print(result["json_response"])
|
332 |
+
|
333 |
+
print("\n" + "="*50)
|
334 |
+
|
335 |
+
if __name__ == "__main__":
|
336 |
+
run_test()
|