Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,13 +30,9 @@ def load_optimized_dataset(data_files):
|
|
30 |
data_frames = [pd.read_csv(file) for file in data_files]
|
31 |
full_data = pd.concat(data_frames, ignore_index=True)
|
32 |
|
33 |
-
# νμΈμ μν λ°μ΄ν° μν μΆλ ₯
|
34 |
-
print(full_data[['μ¬κ±΄λͺ
', 'μ¬κ±΄λ²νΈ', 'νμμ¬ν']].head()) # 'νμμ¬ν' νλμ λ°μ΄ν° μν μΆλ ₯
|
35 |
-
logging.debug(f"Columns in dataset: {full_data.columns}")
|
36 |
-
logging.debug(f"Sample data from 'νμμ¬ν': {full_data['νμμ¬ν'].dropna().head()}")
|
37 |
-
|
38 |
# NaN κ° μ²λ¦¬
|
39 |
full_data['νμμ¬ν'] = full_data['νμμ¬ν'].fillna('')
|
|
|
40 |
|
41 |
# μ¬κ±΄λͺ
μ ν€λ‘ νκ³ μ¬κ±΄λ²νΈμ μ λ¬Έμ μ μ₯νλ λμ
λ리 μμ±
|
42 |
name_to_number = full_data.groupby('μ¬κ±΄λͺ
')['μ¬κ±΄λ²νΈ'].apply(list).to_dict()
|
@@ -116,27 +112,24 @@ async def generate_response(message):
|
|
116 |
user_input = message.content.strip()
|
117 |
user_mention = message.author.mention
|
118 |
|
119 |
-
# μ μ¬ν μ¬κ±΄λͺ
λ° νμμ¬ν μ°ΎκΈ°
|
120 |
matched_case_names = process.extractBests(user_input, all_case_names, limit=3, score_cutoff=70)
|
121 |
matched_case_summaries = process.extractBests(user_input, all_case_summaries, limit=3, score_cutoff=70)
|
122 |
|
123 |
logging.debug(f"Matched case names: {matched_case_names}")
|
124 |
logging.debug(f"Matched case summaries: {matched_case_summaries}")
|
125 |
|
|
|
126 |
if matched_case_names:
|
127 |
-
case_numbers = []
|
128 |
for case_name, score in matched_case_names:
|
129 |
-
|
130 |
-
|
131 |
-
case_numbers_str = "\n".join(case_numbers)
|
132 |
-
system_message = f"{user_mention}, '{user_input}'μ μ μ¬ν μ¬κ±΄λͺ
μ μ¬κ±΄λ²νΈλ λ€μκ³Ό κ°μ΅λλ€:\n{case_numbers_str}"
|
133 |
-
elif matched_case_summaries:
|
134 |
-
case_numbers = []
|
135 |
for case_summary, score in matched_case_summaries:
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
140 |
elif user_input in number_to_fulltext:
|
141 |
full_text = number_to_fulltext[user_input]
|
142 |
system_message = f"{user_mention}, μ¬κ±΄λ²νΈ '{user_input}'μ μ λ¬Έμ λ€μκ³Ό κ°μ΅λλ€:\n\n{full_text}"
|
|
|
30 |
data_frames = [pd.read_csv(file) for file in data_files]
|
31 |
full_data = pd.concat(data_frames, ignore_index=True)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
# NaN κ° μ²λ¦¬
|
34 |
full_data['νμμ¬ν'] = full_data['νμμ¬ν'].fillna('')
|
35 |
+
full_data['μ¬κ±΄λͺ
'] = full_data['μ¬κ±΄λͺ
'].fillna('')
|
36 |
|
37 |
# μ¬κ±΄λͺ
μ ν€λ‘ νκ³ μ¬κ±΄λ²νΈμ μ λ¬Έμ μ μ₯νλ λμ
λ리 μμ±
|
38 |
name_to_number = full_data.groupby('μ¬κ±΄λͺ
')['μ¬κ±΄λ²νΈ'].apply(list).to_dict()
|
|
|
112 |
user_input = message.content.strip()
|
113 |
user_mention = message.author.mention
|
114 |
|
115 |
+
# μ μ¬ν μ¬κ±΄λͺ
λ° νμμ¬ν κ°κ° μ°ΎκΈ°
|
116 |
matched_case_names = process.extractBests(user_input, all_case_names, limit=3, score_cutoff=70)
|
117 |
matched_case_summaries = process.extractBests(user_input, all_case_summaries, limit=3, score_cutoff=70)
|
118 |
|
119 |
logging.debug(f"Matched case names: {matched_case_names}")
|
120 |
logging.debug(f"Matched case summaries: {matched_case_summaries}")
|
121 |
|
122 |
+
case_numbers_set = set()
|
123 |
if matched_case_names:
|
|
|
124 |
for case_name, score in matched_case_names:
|
125 |
+
case_numbers_set.update(name_to_number.get(case_name, []))
|
126 |
+
if matched_case_summaries:
|
|
|
|
|
|
|
|
|
127 |
for case_summary, score in matched_case_summaries:
|
128 |
+
case_numbers_set.update(summary_to_number.get(case_summary, []))
|
129 |
+
|
130 |
+
if case_numbers_set:
|
131 |
+
case_numbers_str = "\n".join(case_numbers_set)
|
132 |
+
system_message = f"{user_mention}, '{user_input}'μ μ μ¬ν μ¬κ±΄μ μ¬κ±΄λ²νΈλ λ€μκ³Ό κ°μ΅λλ€:\n{case_numbers_str}"
|
133 |
elif user_input in number_to_fulltext:
|
134 |
full_text = number_to_fulltext[user_input]
|
135 |
system_message = f"{user_mention}, μ¬κ±΄λ²νΈ '{user_input}'μ μ λ¬Έμ λ€μκ³Ό κ°μ΅λλ€:\n\n{full_text}"
|