0208suin commited on
Commit
bcdfa3b
ยท
verified ยท
1 Parent(s): 4723ed3

Upload medical_chatbot.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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()