Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,49 @@ import json
|
|
7 |
import io
|
8 |
import traceback
|
9 |
import csv
|
10 |
-
# HuggingFace ํด๋ผ์ด์ธํธ ๋์ OpenAI ํด๋ผ์ด์ธํธ ์ฌ์ฉ
|
11 |
from openai import OpenAI
|
12 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# ์ถ๋ก API ํด๋ผ์ด์ธํธ ์ค์
|
15 |
hf_client = InferenceClient(
|
@@ -34,88 +74,24 @@ def load_parquet(filename: str) -> str:
|
|
34 |
except Exception as e:
|
35 |
return f"ํ์ผ์ ์ฝ๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
36 |
|
37 |
-
|
38 |
-
# OpenAI ํด๋ผ์ด์ธํธ ์ค์
|
39 |
-
client = OpenAI(api_key=os.getenv("OPEN_AI"))
|
40 |
-
|
41 |
-
# respond ํจ์ ์์
|
42 |
-
def respond(message: str, history: List[Dict[str, str]], system_message: str = "", max_tokens: int = 4000, temperature: float = 0.5, top_p: float = 0.9, parquet_data: str = None) -> str:
|
43 |
-
# ์์คํ
ํ๋กฌํํธ ์ค์
|
44 |
-
system_prefix = """๋ฐ๋์ ํ๊ธ๋ก ๋ต๋ณํ ๊ฒ. ๋๋ ์
๋ก๋๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ง๋ฌธ์ ๋ต๋ณํ๋ ์ญํ ์ ํ๋ค.
|
45 |
-
|
46 |
-
์ฃผ์ ์ง์นจ:
|
47 |
-
1. ์ง๋ฌธ๊ณผ ์ง์ ๊ด๋ จ๋ ๋ด์ฉ๋ง ๊ฐ๋จ๋ช
๋ฃํ๊ฒ ๋ต๋ณํ ๊ฒ
|
48 |
-
2. ์ด์ ๋ต๋ณ๊ณผ ์ค๋ณต๋๋ ๋ด์ฉ์ ์ ์ธํ ๊ฒ
|
49 |
-
3. ๋ถํ์ํ ์์๋ ๋ถ์ฐ ์ค๋ช
์ ํ์ง ๋ง ๊ฒ
|
50 |
-
4. ๋์ผํ ๋ด์ฉ์ ๋ค๋ฅธ ํํ์ผ๋ก ๋ฐ๋ณตํ์ง ๋ง ๊ฒ
|
51 |
-
5. ํต์ฌ ์ ๋ณด๋ง ์ ๋ฌํ ๊ฒ
|
52 |
-
"""
|
53 |
-
|
54 |
-
if parquet_data:
|
55 |
-
try:
|
56 |
-
df = pd.read_json(io.StringIO(parquet_data))
|
57 |
-
data_summary = df.describe(include='all').to_string()
|
58 |
-
system_prefix += f"\n\n๋ฐ์ดํฐ ์์ฝ:\n{data_summary}"
|
59 |
-
except Exception as e:
|
60 |
-
print(f"๋ฐ์ดํฐ ๋ก๋ ์ค๋ฅ: {str(e)}")
|
61 |
-
|
62 |
-
# ๋ํ ํ์คํ ๋ฆฌ ๊ตฌ์ฑ
|
63 |
-
messages = [{"role": "system", "content": system_prefix}]
|
64 |
-
|
65 |
-
# ์ต๊ทผ ๋ํ ์ปจํ
์คํธ๋ง ์ ์ง
|
66 |
-
recent_history = history[-3:] if history else []
|
67 |
-
for chat in recent_history:
|
68 |
-
messages.append({"role": chat["role"], "content": chat["content"]})
|
69 |
-
|
70 |
-
messages.append({"role": "user", "content": message})
|
71 |
-
|
72 |
-
try:
|
73 |
-
# OpenAI API ํธ์ถ
|
74 |
-
response = client.chat.completions.create(
|
75 |
-
model="gpt-4o-mini", # GPT-4-mini ๋ชจ๋ธ ์ฌ์ฉ
|
76 |
-
messages=messages,
|
77 |
-
max_tokens=max_tokens,
|
78 |
-
temperature=temperature,
|
79 |
-
top_p=top_p,
|
80 |
-
stream=True
|
81 |
-
)
|
82 |
-
|
83 |
-
full_response = ""
|
84 |
-
for chunk in response:
|
85 |
-
if chunk.choices[0].delta.content:
|
86 |
-
full_response += chunk.choices[0].delta.content
|
87 |
-
# ์๋ต ์ ์
|
88 |
-
cleaned_response = clean_response(full_response)
|
89 |
-
yield cleaned_response
|
90 |
-
|
91 |
-
except Exception as e:
|
92 |
-
error_message = f"์ถ๋ก ์ค๋ฅ: {str(e)}"
|
93 |
-
print(error_message)
|
94 |
-
yield error_message
|
95 |
-
|
96 |
def clean_response(text: str) -> str:
|
97 |
"""์๋ต ํ
์คํธ ์ ์ ํจ์"""
|
98 |
-
# ๋ฌธ์ฅ ๋จ์๋ก ๋ถ๋ฆฌ
|
99 |
sentences = [s.strip() for s in text.split('.') if s.strip()]
|
100 |
-
|
101 |
-
# ์ค๋ณต ์ ๊ฑฐ
|
102 |
unique_sentences = []
|
103 |
seen = set()
|
104 |
|
105 |
for sentence in sentences:
|
106 |
-
# ๋ฌธ์ฅ ์ ๊ทํ (๊ณต๋ฐฑ ์ ๊ฑฐ, ์๋ฌธ์ ๋ณํ)
|
107 |
normalized = ' '.join(sentence.lower().split())
|
108 |
if normalized not in seen:
|
109 |
seen.add(normalized)
|
110 |
unique_sentences.append(sentence)
|
111 |
|
112 |
-
# ์ ์ ๋ ๋ฌธ์ฅ ๊ฒฐํฉ
|
113 |
cleaned_text = '. '.join(unique_sentences)
|
114 |
if cleaned_text and not cleaned_text.endswith('.'):
|
115 |
cleaned_text += '.'
|
116 |
|
117 |
return cleaned_text
|
118 |
-
|
119 |
def remove_duplicates(text: str) -> str:
|
120 |
"""์ค๋ณต ๋ฌธ์ฅ ์ ๊ฑฐ ํจ์"""
|
121 |
sentences = text.split('.')
|
@@ -132,20 +108,17 @@ def remove_duplicates(text: str) -> str:
|
|
132 |
|
133 |
def upload_csv(file_path: str) -> Tuple[str, str]:
|
134 |
try:
|
135 |
-
# CSV ํ์ผ ์ฝ๊ธฐ
|
136 |
df = pd.read_csv(file_path, sep=',')
|
137 |
-
# ํ์ ์ปฌ๋ผ ํ์ธ
|
138 |
required_columns = {'id', 'text', 'label', 'metadata'}
|
139 |
available_columns = set(df.columns)
|
140 |
missing_columns = required_columns - available_columns
|
141 |
if missing_columns:
|
142 |
return f"CSV ํ์ผ์ ๋ค์ ํ์ ์ปฌ๋ผ์ด ๋๋ฝ๋์์ต๋๋ค: {', '.join(missing_columns)}", ""
|
143 |
-
|
144 |
df.drop_duplicates(inplace=True)
|
145 |
df.fillna('', inplace=True)
|
146 |
-
# ๋ฐ์ดํฐ ์ ํ ์ต์ ํ
|
147 |
df = df.astype({'id': 'int32', 'text': 'string', 'label': 'category', 'metadata': 'string'})
|
148 |
-
|
149 |
parquet_filename = os.path.splitext(os.path.basename(file_path))[0] + '.parquet'
|
150 |
df.to_parquet(parquet_filename, engine='pyarrow', compression='snappy')
|
151 |
return f"{parquet_filename} ํ์ผ์ด ์ฑ๊ณต์ ์ผ๋ก ์
๋ก๋๋๊ณ ๋ณํ๋์์ต๋๋ค.", parquet_filename
|
@@ -154,10 +127,8 @@ def upload_csv(file_path: str) -> Tuple[str, str]:
|
|
154 |
|
155 |
def upload_parquet(file_path: str) -> Tuple[str, str, str]:
|
156 |
try:
|
157 |
-
# Parquet ํ์ผ ์ฝ๊ธฐ
|
158 |
df = pd.read_parquet(file_path, engine='pyarrow')
|
159 |
|
160 |
-
# ๋ฐ์ดํฐ ๊ธฐ๋ณธ ์ ๋ณด ์์ง
|
161 |
data_info = {
|
162 |
"์ด ๋ ์ฝ๋ ์": len(df),
|
163 |
"์ปฌ๋ผ ๋ชฉ๋ก": list(df.columns),
|
@@ -165,143 +136,53 @@ def upload_parquet(file_path: str) -> Tuple[str, str, str]:
|
|
165 |
"๊ฒฐ์ธก์น ์ ๋ณด": df.isnull().sum().to_dict()
|
166 |
}
|
167 |
|
168 |
-
# ๋ฐ์ดํฐ ์์ฝ ์ ๋ณด ์์ฑ
|
169 |
summary = []
|
170 |
summary.append(f"### ๋ฐ์ดํฐ์
๊ธฐ๋ณธ ์ ๋ณด:")
|
171 |
summary.append(f"- ์ด ๋ ์ฝ๋ ์: {data_info['์ด ๋ ์ฝ๋ ์']}")
|
172 |
summary.append(f"- ์ปฌ๋ผ ๋ชฉ๋ก: {', '.join(data_info['์ปฌ๋ผ ๋ชฉ๋ก'])}")
|
173 |
|
174 |
-
# ๊ฐ ์ปฌ๋ผ๋ณ ํต๊ณ ์ ๋ณด ์์ฑ
|
175 |
summary.append("\n### ์ปฌ๋ผ๋ณ ์ ๋ณด:")
|
176 |
for col in df.columns:
|
177 |
if df[col].dtype in ['int64', 'float64']:
|
178 |
-
# ์์นํ ๋ฐ์ดํฐ
|
179 |
stats = df[col].describe()
|
180 |
summary.append(f"\n{col} (์์นํ):")
|
181 |
summary.append(f"- ํ๊ท : {stats['mean']:.2f}")
|
182 |
summary.append(f"- ์ต์: {stats['min']}")
|
183 |
summary.append(f"- ์ต๋: {stats['max']}")
|
184 |
elif df[col].dtype == 'object' or df[col].dtype == 'string':
|
185 |
-
# ๋ฌธ์์ด ๋ฐ์ดํฐ
|
186 |
unique_count = df[col].nunique()
|
187 |
summary.append(f"\n{col} (ํ
์คํธ):")
|
188 |
summary.append(f"- ๊ณ ์ ๊ฐ ์: {unique_count}")
|
189 |
-
if unique_count < 10:
|
190 |
value_counts = df[col].value_counts().head(5)
|
191 |
summary.append("- ์์ 5๊ฐ ๊ฐ:")
|
192 |
for val, count in value_counts.items():
|
193 |
summary.append(f" โข {val}: {count}๊ฐ")
|
194 |
|
195 |
-
# ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ฑ
|
196 |
preview = df.head(10).to_markdown(index=False)
|
197 |
summary.append("\n### ๋ฐ์ดํฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ:")
|
198 |
summary.append(preview)
|
199 |
|
200 |
parquet_content = "\n".join(summary)
|
201 |
-
|
202 |
-
# DataFrame์ JSON ๋ฌธ์์ด๋ก ๋ณํ (Q&A์์ ์ฌ์ฉ)
|
203 |
parquet_json = df.to_json(orient='records', force_ascii=False)
|
204 |
|
205 |
return "Parquet ํ์ผ์ด ์ฑ๊ณต์ ์ผ๋ก ์
๋ก๋๋์์ต๋๋ค.", parquet_content, parquet_json
|
206 |
except Exception as e:
|
207 |
return f"Parquet ํ์ผ ์
๋ก๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", "", ""
|
208 |
|
209 |
-
|
210 |
-
def respond(message: str, history: List[Dict[str, str]], system_message: str = "", max_tokens: int = 4000, temperature: float = 0.5, top_p: float = 0.9, parquet_data: str = None) -> str:
|
211 |
-
try:
|
212 |
-
if parquet_data:
|
213 |
-
# JSON ๋ฌธ์์ด์ DataFrame์ผ๋ก ๋ณํ
|
214 |
-
df = pd.read_json(io.StringIO(parquet_data))
|
215 |
-
|
216 |
-
# ๋ฐ์ดํฐ์
์ปจํ
์คํธ ์์ฑ
|
217 |
-
columns_info = []
|
218 |
-
for col in df.columns:
|
219 |
-
if df[col].dtype in ['int64', 'float64']:
|
220 |
-
col_type = "์์นํ"
|
221 |
-
stats = df[col].describe()
|
222 |
-
col_info = f"- {col} ({col_type}): ํ๊ท ={stats['mean']:.2f}, ์ต์={stats['min']}, ์ต๋={stats['max']}"
|
223 |
-
else:
|
224 |
-
col_type = "ํ
์คํธ"
|
225 |
-
unique_count = df[col].nunique()
|
226 |
-
col_info = f"- {col} ({col_type}): ๊ณ ์ ๊ฐ {unique_count}๊ฐ"
|
227 |
-
columns_info.append(col_info)
|
228 |
-
|
229 |
-
data_context = f"""
|
230 |
-
ํ์ฌ ์
๋ก๋๋ ๋ฐ์ดํฐ์
์ ๋ณด:
|
231 |
-
- ์ด {len(df)} ๊ฐ์ ๋ ์ฝ๋
|
232 |
-
- ์ปฌ๋ผ ์ ๋ณด:
|
233 |
-
{chr(10).join(columns_info)}
|
234 |
-
|
235 |
-
์ํ ๋ฐ์ดํฐ:
|
236 |
-
{df.head(20).to_string()}
|
237 |
-
"""
|
238 |
-
system_prompt = f"""๋น์ ์ ์
๋ก๋๋ ๋ฐ์ดํฐ์
์ ๋ถ์ํ๊ณ ์ง๋ฌธ์ ๋ต๋ณํ๋ AI ์ด์์คํดํธ์
๋๋ค.
|
239 |
-
|
240 |
-
์ฃผ์ ์ง์นจ:
|
241 |
-
1. ๋ฐ๋์ ํ๊ธ๋ก ๋ต๋ณํ ๊ฒ
|
242 |
-
2. ๋ฐ์ดํฐ์
์ ์ค์ ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ์ ํํ๊ฒ ๋ต๋ณํ ๊ฒ
|
243 |
-
3. ๋ฐ์ดํฐ์ ์๋ ๋ด์ฉ์ ์ถ์ธกํ์ง ๋ง ๊ฒ
|
244 |
-
4. ๋ต๋ณ์ ๊ฐ๋จ๋ช
๋ฃํ๊ฒ ํ ๊ฒ
|
245 |
-
5. ๋ฐ์ดํฐ ํ๋ผ์ด๋ฒ์๋ฅผ ๊ณ ๋ คํ์ฌ ๋ต๋ณํ ๊ฒ
|
246 |
-
|
247 |
-
๋ฐ์ดํฐ์
๊ตฌ์กฐ ์ค๋ช
:
|
248 |
-
{chr(10).join(columns_info)}
|
249 |
-
|
250 |
-
์ฐธ๊ณ ํ ๋ฐ์ดํฐ ์ํ:
|
251 |
-
{data_context}
|
252 |
-
"""
|
253 |
-
else:
|
254 |
-
system_prompt = system_message or "๋๋ AI ์กฐ์ธ์ ์ญํ ์ด๋ค."
|
255 |
-
|
256 |
-
# OpenAI API ํธ์ถ
|
257 |
-
messages = [{"role": "system", "content": system_prompt}]
|
258 |
-
|
259 |
-
# ์ต๊ทผ ๋ํ ๊ธฐ๋ก ์ถ๊ฐ
|
260 |
-
recent_history = history[-3:] if history else []
|
261 |
-
for chat in recent_history:
|
262 |
-
messages.append({"role": chat["role"], "content": chat["content"]})
|
263 |
-
|
264 |
-
messages.append({"role": "user", "content": message})
|
265 |
-
|
266 |
-
response = client.chat.completions.create(
|
267 |
-
model="gpt-4-0125-preview",
|
268 |
-
messages=messages,
|
269 |
-
max_tokens=max_tokens,
|
270 |
-
temperature=temperature,
|
271 |
-
top_p=top_p,
|
272 |
-
stream=True
|
273 |
-
)
|
274 |
-
|
275 |
-
full_response = ""
|
276 |
-
for chunk in response:
|
277 |
-
if chunk.choices[0].delta.content:
|
278 |
-
full_response += chunk.choices[0].delta.content
|
279 |
-
yield clean_response(full_response)
|
280 |
-
|
281 |
-
except Exception as e:
|
282 |
-
error_message = f"์๋ต ์์ฑ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
283 |
-
print(f"{error_message}\n{traceback.format_exc()}")
|
284 |
-
yield error_message
|
285 |
-
|
286 |
def text_to_parquet(text: str) -> Tuple[str, str, str]:
|
287 |
try:
|
288 |
-
# ์
๋ ฅ ํ
์คํธ๋ฅผ ์ค ๋จ์๋ก ๋ถ๋ฆฌ
|
289 |
lines = [line.strip() for line in text.split('\n') if line.strip()]
|
290 |
-
|
291 |
-
# ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ๋ฆฌ์คํธ
|
292 |
data = []
|
293 |
|
294 |
for line in lines:
|
295 |
try:
|
296 |
-
# ์ ๊ท์์ ์ฌ์ฉํ์ฌ CSV ํ์ ํ์ฑ
|
297 |
import re
|
298 |
pattern = r'(\d+),([^,]+),([^,]+),(.+)'
|
299 |
match = re.match(pattern, line)
|
300 |
|
301 |
if match:
|
302 |
id_val, text_val, label_val, metadata_val = match.groups()
|
303 |
-
|
304 |
-
# ์๋ฐ์ดํ ์ ๊ฑฐ ๋ฐ ์ ์
|
305 |
text_val = text_val.strip().strip('"')
|
306 |
label_val = label_val.strip().strip('"')
|
307 |
metadata_val = metadata_val.strip().strip('"')
|
@@ -319,10 +200,7 @@ def text_to_parquet(text: str) -> Tuple[str, str, str]:
|
|
319 |
if not data:
|
320 |
return "๋ณํํ ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค.", "", ""
|
321 |
|
322 |
-
# DataFrame ์์ฑ
|
323 |
df = pd.DataFrame(data)
|
324 |
-
|
325 |
-
# ๋ฐ์ดํฐ ํ์
์ค์
|
326 |
df = df.astype({
|
327 |
'id': 'int32',
|
328 |
'text': 'string',
|
@@ -330,11 +208,8 @@ def text_to_parquet(text: str) -> Tuple[str, str, str]:
|
|
330 |
'metadata': 'string'
|
331 |
})
|
332 |
|
333 |
-
# Parquet ํ์ผ๋ก ๋ณํ
|
334 |
parquet_filename = 'text_to_parquet.parquet'
|
335 |
df.to_parquet(parquet_filename, engine='pyarrow', compression='snappy')
|
336 |
-
|
337 |
-
# ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ฑ
|
338 |
preview = df.to_markdown(index=False)
|
339 |
|
340 |
return (
|
@@ -348,34 +223,46 @@ def text_to_parquet(text: str) -> Tuple[str, str, str]:
|
|
348 |
print(f"{error_message}\n{traceback.format_exc()}")
|
349 |
return error_message, "", ""
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
return
|
355 |
-
|
356 |
-
system_prompt = """๋ฐ๋์ ํ๊ธ(ํ๊ตญ์ด)๋ก ๋ต๋ณํ์์ค. ๋น์ ์ ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ ์ ๋ฌธ๊ฐ์
๋๋ค. ์
๋ ฅ๋ ํ
์คํธ๋ฅผ CSV ๋ฐ์ดํฐ์
ํ์์ผ๋ก ๋ณํํ์ธ์.
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
|
370 |
try:
|
371 |
response = client.chat.completions.create(
|
372 |
model="gpt-4-0125-preview",
|
373 |
-
messages=
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
max_tokens=4000,
|
378 |
-
temperature=0.1,
|
379 |
stream=True
|
380 |
)
|
381 |
|
@@ -383,26 +270,19 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
383 |
for chunk in response:
|
384 |
if chunk.choices[0].delta.content:
|
385 |
full_response += chunk.choices[0].delta.content
|
|
|
386 |
|
387 |
-
# ์๋ต ์ ์
|
388 |
-
processed_text = clean_response(full_response)
|
389 |
-
|
390 |
-
# CSV ํ์ ๊ฒ์ฆ
|
391 |
-
try:
|
392 |
-
from io import StringIO
|
393 |
-
import csv
|
394 |
-
csv.reader(StringIO(processed_text))
|
395 |
-
return processed_text
|
396 |
-
except csv.Error:
|
397 |
-
return "LLM์ด ์ฌ๋ฐ๋ฅธ CSV ํ์์ ์์ฑํ์ง ๋ชปํ์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์."
|
398 |
-
|
399 |
except Exception as e:
|
400 |
-
error_message = f"
|
401 |
-
print(error_message)
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
|
|
|
|
|
|
|
|
406 |
|
407 |
system_prompt = """๋ฐ๋์ ํ๊ธ(ํ๊ตญ์ด)๋ก ๋ต๋ณํ์์ค. ๋น์ ์ ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ ์ ๋ฌธ๊ฐ์
๋๋ค. ์
๋ ฅ๋ ํ
์คํธ๋ฅผ CSV ๋ฐ์ดํฐ์
ํ์์ผ๋ก ๋ณํํ์ธ์.
|
408 |
|
@@ -420,7 +300,7 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
420 |
|
421 |
try:
|
422 |
response = client.chat.completions.create(
|
423 |
-
model="gpt-
|
424 |
messages=[
|
425 |
{"role": "system", "content": system_prompt},
|
426 |
{"role": "user", "content": input_text}
|
@@ -435,10 +315,8 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
435 |
if chunk.choices[0].delta.content:
|
436 |
full_response += chunk.choices[0].delta.content
|
437 |
|
438 |
-
# ์๋ต ์ ์
|
439 |
processed_text = clean_response(full_response)
|
440 |
|
441 |
-
# CSV ํ์ ๊ฒ์ฆ
|
442 |
try:
|
443 |
from io import StringIO
|
444 |
import csv
|
@@ -452,46 +330,50 @@ def preprocess_text_with_llm(input_text: str) -> str:
|
|
452 |
print(error_message)
|
453 |
return error_message
|
454 |
|
455 |
-
# CSS ์ค์
|
456 |
-
css = """
|
457 |
-
footer {
|
458 |
-
visibility: hidden;
|
459 |
-
}
|
460 |
-
#chatbot-container, #chatbot-data-upload {
|
461 |
-
height: 700px;
|
462 |
-
overflow-y: scroll;
|
463 |
-
}
|
464 |
-
#chatbot-container .message, #chatbot-data-upload .message {
|
465 |
-
font-size: 14px;
|
466 |
-
}
|
467 |
-
/* ์
๋ ฅ์ฐฝ ๋ฐฐ๊ฒฝ์ ๋ฐ ๊ธ์์ ๋ณ๊ฒฝ */
|
468 |
-
textarea, input[type="text"] {
|
469 |
-
background-color: #ffffff; /* ํฐ์ ๋ฐฐ๊ฒฝ */
|
470 |
-
color: #000000; /* ๊ฒ์ ์ ๊ธ์ */
|
471 |
-
}
|
472 |
-
/* ํ์ผ ์
๋ก๋ ์์ญ ๋์ด ์กฐ์ */
|
473 |
-
#parquet-upload-area {
|
474 |
-
max-height: 150px;
|
475 |
-
overflow-y: auto;
|
476 |
-
}
|
477 |
-
/* ์ด๊ธฐ ์ค๋ช
๊ธ์จ ํฌ๊ธฐ ์กฐ์ */
|
478 |
-
#initial-description {
|
479 |
-
font-size: 14px;
|
480 |
-
}
|
481 |
-
"""
|
482 |
|
483 |
# Gradio Blocks ์ธํฐํ์ด์ค ์ค์
|
484 |
with gr.Blocks(css=css) as demo:
|
|
|
|
|
485 |
gr.Markdown("# MyEzRAG: LLM์ด ๋๋ง์ ๋ฐ์ดํฐ๋ก ํ์ตํ ์ฝํ
์ธ ์์ฑ/๋ต๋ณ", elem_id="initial-description")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
gr.Markdown(
|
487 |
"### '์ฌ์ฉ ๋ฐฉ๋ฒ' ํญ์ ํตํด ์์ธํ ์ด์ฉ ๋ฐฉ๋ฒ์ ์ฐธ๊ณ ํ์ธ์.\n"
|
488 |
"### Tip) '์์ '๋ฅผ ํตํด ๋ค์ํ ํ์ฉ ๋ฐฉ๋ฒ์ ์ฒดํํ๊ณ ์์ฉํด ๋ณด์ธ์, ๋ฐ์ดํฐ์
์
๋ก๋์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ 10๊ฑด๋ง ์ถ๋ ฅ",
|
489 |
elem_id="initial-description"
|
490 |
)
|
491 |
|
492 |
-
|
493 |
-
|
494 |
-
# ์ฒซ ๋ฒ์งธ ํญ: ์ฑ๋ด ๋ฐ์ดํฐ ์
๋ก๋ (ํญ ์ด๋ฆ ๋ณ๊ฒฝ: "My ๋ฐ์ดํฐ์
+LLM")
|
495 |
with gr.Tab("My ๋ฐ์ดํฐ์
+LLM"):
|
496 |
gr.Markdown("### LLM๊ณผ ๋ํํ๊ธฐ")
|
497 |
chatbot_data_upload = gr.Chatbot(label="์ฑ๋ด", type="messages", elem_id="chatbot-data-upload")
|
@@ -506,10 +388,14 @@ with gr.Blocks(css=css) as demo:
|
|
506 |
|
507 |
parquet_data_state = gr.State()
|
508 |
|
509 |
-
def handle_message_data_upload(message: str, history: List[Dict[str, str]], system_message: str, max_tokens: int, temperature: float, top_p: float, parquet_data: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
history = history or []
|
511 |
-
|
512 |
-
# ์ค๋ณต ์ง๋ฌธ ๊ฒ์ฌ
|
513 |
recent_questions = [chat['content'].strip().lower() for chat in history[-3:] if chat['role'] == 'user']
|
514 |
if message.strip().lower() in recent_questions:
|
515 |
yield history + [{"role": "assistant", "content": "๋์ผํ ์ง๋ฌธ์ด ์ต๊ทผ์ ์์์ต๋๋ค. ๋ค๋ฅธ ์ง๋ฌธ์ ํด์ฃผ์ธ์."}], ""
|
@@ -522,9 +408,10 @@ with gr.Blocks(css=css) as demo:
|
|
522 |
history,
|
523 |
system_message,
|
524 |
max_tokens,
|
525 |
-
temperature=0.3,
|
526 |
top_p=top_p,
|
527 |
-
parquet_data=parquet_data
|
|
|
528 |
)
|
529 |
|
530 |
partial_response = ""
|
@@ -539,9 +426,6 @@ with gr.Blocks(css=css) as demo:
|
|
539 |
history.append({"role": "assistant", "content": response})
|
540 |
yield history, ""
|
541 |
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
send_data_upload.click(
|
546 |
handle_message_data_upload,
|
547 |
inputs=[
|
@@ -551,13 +435,14 @@ with gr.Blocks(css=css) as demo:
|
|
551 |
max_tokens,
|
552 |
temperature,
|
553 |
top_p,
|
554 |
-
parquet_data_state,
|
|
|
555 |
],
|
556 |
outputs=[chatbot_data_upload, msg_data_upload],
|
557 |
queue=True
|
558 |
)
|
559 |
|
560 |
-
|
561 |
with gr.Accordion("์์ ", open=False):
|
562 |
gr.Examples(
|
563 |
examples=[
|
@@ -572,7 +457,7 @@ with gr.Blocks(css=css) as demo:
|
|
572 |
label="์์ ์ ํ",
|
573 |
)
|
574 |
|
575 |
-
# Parquet ํ์ผ
|
576 |
gr.Markdown("### Parquet ํ์ผ ์
๋ก๋")
|
577 |
with gr.Row():
|
578 |
with gr.Column():
|
@@ -596,7 +481,7 @@ with gr.Blocks(css=css) as demo:
|
|
596 |
outputs=[parquet_upload_status, parquet_preview_chat, parquet_data_state]
|
597 |
)
|
598 |
|
599 |
-
# ๋ ๋ฒ์งธ ํญ:
|
600 |
with gr.Tab("CSV to My ๋ฐ์ดํฐ์
"):
|
601 |
gr.Markdown("### CSV ํ์ผ ์
๋ก๋ ๋ฐ Parquet ๋ณํ")
|
602 |
with gr.Row():
|
@@ -621,7 +506,7 @@ with gr.Blocks(css=css) as demo:
|
|
621 |
outputs=[upload_status, parquet_preview, download_button]
|
622 |
)
|
623 |
|
624 |
-
# ์ธ ๋ฒ์งธ ํญ:
|
625 |
with gr.Tab("Text to My ๋ฐ์ดํฐ์
"):
|
626 |
gr.Markdown("### ํ
์คํธ๋ฅผ ์
๋ ฅํ๋ฉด CSV๋ก ๋ณํ ํ Parquet์ผ๋ก ์๋ ์ ํ๋ฉ๋๋ค.")
|
627 |
with gr.Row():
|
@@ -649,7 +534,7 @@ with gr.Blocks(css=css) as demo:
|
|
649 |
outputs=[convert_status, parquet_preview_convert, download_parquet_convert]
|
650 |
)
|
651 |
|
652 |
-
#
|
653 |
with gr.Tab("Text Preprocessing with LLM"):
|
654 |
gr.Markdown("### ํ
์คํธ๋ฅผ ์
๋ ฅํ๋ฉด LLM์ด ๋ฐ์ดํฐ์
ํ์์ ๋ง๊ฒ ์ ์ฒ๋ฆฌํ์ฌ ์ถ๋ ฅํฉ๋๋ค.")
|
655 |
with gr.Row():
|
@@ -676,33 +561,29 @@ with gr.Blocks(css=css) as demo:
|
|
676 |
interactive=False
|
677 |
)
|
678 |
|
679 |
-
# Parquet ๋ณํ ๋ฐ ๋ค์ด๋ก๋ ์น์
|
680 |
convert_to_parquet_button = gr.Button("Parquet์ผ๋ก ๋ณํ")
|
681 |
download_parquet = gr.File(label="๋ณํ๋ Parquet ํ์ผ ๋ค์ด๋ก๋")
|
682 |
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
|
|
687 |
if not input_text.strip():
|
688 |
-
|
|
|
689 |
|
690 |
try:
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
processed_text = preprocess_text_with_llm(input_text)
|
695 |
|
696 |
if processed_text:
|
697 |
-
|
698 |
-
yield preprocess_status_msg, processed_text
|
699 |
else:
|
700 |
-
|
701 |
-
yield preprocess_status_msg, ""
|
702 |
|
703 |
except Exception as e:
|
704 |
-
|
705 |
-
yield error_msg, ""
|
706 |
|
707 |
def clear_inputs():
|
708 |
return "", "๋๊ธฐ ์ค...", ""
|
@@ -719,10 +600,9 @@ with gr.Blocks(css=css) as demo:
|
|
719 |
except Exception as e:
|
720 |
return f"Parquet ๋ณํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}", None
|
721 |
|
722 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ฐ๊ฒฐ
|
723 |
preprocess_button.click(
|
724 |
handle_text_preprocessing,
|
725 |
-
inputs=[raw_text_input],
|
726 |
outputs=[preprocess_status, processed_text_output],
|
727 |
queue=True
|
728 |
)
|
@@ -738,7 +618,6 @@ with gr.Blocks(css=css) as demo:
|
|
738 |
outputs=[preprocess_status, download_parquet]
|
739 |
)
|
740 |
|
741 |
-
# ์์ ํ
์คํธ ์ถ๊ฐ
|
742 |
with gr.Accordion("์์ ํ
์คํธ", open=False):
|
743 |
gr.Examples(
|
744 |
examples=[
|
@@ -749,12 +628,17 @@ with gr.Blocks(css=css) as demo:
|
|
749 |
label="์์ ์ ํ"
|
750 |
)
|
751 |
|
|
|
752 |
with gr.Tab("๐ ์ฌ์ฉ ๋ฐฉ๋ฒ"):
|
753 |
gr.Markdown("""
|
754 |
# MyEzRAG ์ฌ์ฉ ๊ฐ์ด๋
|
755 |
|
|
|
|
|
|
|
|
|
|
|
756 |
## 1๏ธโฃ My ๋ฐ์ดํฐ์
+LLM ํญ
|
757 |
-
![Tab1](https://your-image-url.com/tab1.png)
|
758 |
### ๊ธฐ๋ฅ
|
759 |
- ์
๋ก๋๋ Parquet ๋ฐ์ดํฐ์
์ ๊ธฐ๋ฐ์ผ๋ก LLM๊ณผ ๋ํ
|
760 |
- ๋ฐ์ดํฐ์
์ ๋ด์ฉ์ ํ์ฉํ ์ฝํ
์ธ ์์ฑ
|
@@ -771,7 +655,6 @@ with gr.Blocks(css=css) as demo:
|
|
771 |
---
|
772 |
|
773 |
## 2๏ธโฃ CSV to My ๋ฐ์ดํฐ์
ํญ
|
774 |
-
![Tab2](https://your-image-url.com/tab2.png)
|
775 |
### ๊ธฐ๋ฅ
|
776 |
- CSV ํ์ผ์ Parquet ํ์์ผ๋ก ๋ณํ
|
777 |
- ๋ฐ์ดํฐ ์ต์ ํ ๋ฐ ์ ์
|
@@ -788,7 +671,6 @@ with gr.Blocks(css=css) as demo:
|
|
788 |
---
|
789 |
|
790 |
## 3๏ธโฃ Text to My ๋ฐ์ดํฐ์
ํญ
|
791 |
-
![Tab3](https://your-image-url.com/tab3.png)
|
792 |
### ๊ธฐ๋ฅ
|
793 |
- ํ
์คํธ ํ์์ ๋ฐ์ดํฐ๋ฅผ Parquet์ผ๋ก ๋ณํ
|
794 |
- ์๋ ๋ฐ์ดํฐ ์
๋ ฅ ์ง์
|
@@ -811,7 +693,6 @@ with gr.Blocks(css=css) as demo:
|
|
811 |
---
|
812 |
|
813 |
## 4๏ธโฃ Text Preprocessing with LLM ํญ
|
814 |
-
![Tab4](https://your-image-url.com/tab4.png)
|
815 |
### ๊ธฐ๋ฅ
|
816 |
- LLM์ ํ์ฉํ ์๋ ํ
์คํธ ์ ์ฒ๋ฆฌ
|
817 |
- ๊ตฌ์กฐํ๋ ๋ฐ์ดํฐ์
์์ฑ
|
@@ -828,26 +709,28 @@ with gr.Blocks(css=css) as demo:
|
|
828 |
- ๋ฐ์ดํฐ ์ ๊ทํ
|
829 |
|
830 |
## ๐ก ์ผ๋ฐ์ ์ธ ํ
|
|
|
831 |
- ๊ฐ ํญ์ ์์ ๋ฅผ ์ฐธ๊ณ ํ์ฌ ์ฌ์ฉ๋ฒ ๏ฟฝ๏ฟฝํ๊ธฐ
|
832 |
- ๋ฐ์ดํฐ ํ์ง์ด ์ข์์๋ก ๋ ๋์ ๊ฒฐ๊ณผ ์ ๊ณต
|
833 |
- ์ค๋ฅ ๋ฐ์ ์ ์
๋ ฅ ๋ฐ์ดํฐ ํ์ ํ์ธ
|
834 |
- ๋์ฉ๋ ์ฒ๋ฆฌ ์ ์ ์ ํ ์ฒญํฌ ํฌ๊ธฐ๋ก ๋ถํ ์ฒ๋ฆฌ
|
835 |
|
836 |
## โ ๏ธ ์ฃผ์์ฌํญ
|
|
|
837 |
- ๋ฏผ๊ฐํ ๊ฐ์ธ์ ๋ณด ํฌํจํ์ง ์๊ธฐ
|
838 |
- ๋ฐ์ดํฐ ๋ฐฑ์
๊ถ์ฅ
|
839 |
- ๋คํธ์ํฌ ์ํ ํ์ธ
|
840 |
- ๋ธ๋ผ์ฐ์ ์บ์ ์ฃผ๊ธฐ์ ์ ๋ฆฌ
|
841 |
|
842 |
## ๐ ๋ฌธ์ ํด๊ฒฐ
|
|
|
843 |
- ์ค๋ฅ ๋ฐ์ ์ ์
๋ ฅ ๋ฐ์ดํฐ ํ์ ํ์ธ
|
844 |
- ํ์ผ ์
๋ก๋ ์คํจ ์ ํ์ผ ํฌ๊ธฐ ๋ฐ ํ์ ํ์ธ
|
845 |
- ๋ณํ ์คํจ ์ ๋ฐ์ดํฐ ์ธ์ฝ๋ฉ ํ์ธ
|
846 |
- ์๋ต์ด ๋๋ฆด ๊ฒฝ์ฐ ๋ฐ์ดํฐ ํฌ๊ธฐ ์กฐ์
|
847 |
""")
|
848 |
|
849 |
-
|
850 |
gr.Markdown("### [email protected]", elem_id="initial-description")
|
851 |
|
852 |
if __name__ == "__main__":
|
853 |
-
demo.launch(share=True)
|
|
|
7 |
import io
|
8 |
import traceback
|
9 |
import csv
|
|
|
10 |
from openai import OpenAI
|
11 |
+
from functools import lru_cache
|
12 |
+
from concurrent.futures import ThreadPoolExecutor
|
13 |
+
import math
|
14 |
+
|
15 |
+
# CSS ์ค์
|
16 |
+
css = """
|
17 |
+
footer {
|
18 |
+
visibility: hidden;
|
19 |
+
}
|
20 |
+
#chatbot-container, #chatbot-data-upload {
|
21 |
+
height: 700px;
|
22 |
+
overflow-y: scroll;
|
23 |
+
}
|
24 |
+
#chatbot-container .message, #chatbot-data-upload .message {
|
25 |
+
font-size: 14px;
|
26 |
+
}
|
27 |
+
/* ์
๋ ฅ์ฐฝ ๋ฐฐ๊ฒฝ์ ๋ฐ ๊ธ์์ ๋ณ๊ฒฝ */
|
28 |
+
textarea, input[type="text"] {
|
29 |
+
background-color: #ffffff;
|
30 |
+
color: #000000;
|
31 |
+
}
|
32 |
+
/* ํ์ผ ์
๋ก๋ ์์ญ ๋์ด ์กฐ์ */
|
33 |
+
#parquet-upload-area {
|
34 |
+
max-height: 150px;
|
35 |
+
overflow-y: auto;
|
36 |
+
}
|
37 |
+
/* ์ด๊ธฐ ์ค๋ช
๊ธ์จ ํฌ๊ธฐ ์กฐ์ */
|
38 |
+
#initial-description {
|
39 |
+
font-size: 14px;
|
40 |
+
}
|
41 |
+
/* API Key ์
๋ ฅ ์น์
์คํ์ผ */
|
42 |
+
.api-key-section {
|
43 |
+
margin: 10px 0;
|
44 |
+
padding: 10px;
|
45 |
+
border: 1px solid #ddd;
|
46 |
+
border-radius: 5px;
|
47 |
+
}
|
48 |
+
.api-key-status {
|
49 |
+
margin-top: 5px;
|
50 |
+
font-weight: bold;
|
51 |
+
}
|
52 |
+
"""
|
53 |
|
54 |
# ์ถ๋ก API ํด๋ผ์ด์ธํธ ์ค์
|
55 |
hf_client = InferenceClient(
|
|
|
74 |
except Exception as e:
|
75 |
return f"ํ์ผ์ ์ฝ๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
def clean_response(text: str) -> str:
|
78 |
"""์๋ต ํ
์คํธ ์ ์ ํจ์"""
|
|
|
79 |
sentences = [s.strip() for s in text.split('.') if s.strip()]
|
|
|
|
|
80 |
unique_sentences = []
|
81 |
seen = set()
|
82 |
|
83 |
for sentence in sentences:
|
|
|
84 |
normalized = ' '.join(sentence.lower().split())
|
85 |
if normalized not in seen:
|
86 |
seen.add(normalized)
|
87 |
unique_sentences.append(sentence)
|
88 |
|
|
|
89 |
cleaned_text = '. '.join(unique_sentences)
|
90 |
if cleaned_text and not cleaned_text.endswith('.'):
|
91 |
cleaned_text += '.'
|
92 |
|
93 |
return cleaned_text
|
94 |
+
|
95 |
def remove_duplicates(text: str) -> str:
|
96 |
"""์ค๋ณต ๋ฌธ์ฅ ์ ๊ฑฐ ํจ์"""
|
97 |
sentences = text.split('.')
|
|
|
108 |
|
109 |
def upload_csv(file_path: str) -> Tuple[str, str]:
|
110 |
try:
|
|
|
111 |
df = pd.read_csv(file_path, sep=',')
|
|
|
112 |
required_columns = {'id', 'text', 'label', 'metadata'}
|
113 |
available_columns = set(df.columns)
|
114 |
missing_columns = required_columns - available_columns
|
115 |
if missing_columns:
|
116 |
return f"CSV ํ์ผ์ ๋ค์ ํ์ ์ปฌ๋ผ์ด ๋๋ฝ๋์์ต๋๋ค: {', '.join(missing_columns)}", ""
|
117 |
+
|
118 |
df.drop_duplicates(inplace=True)
|
119 |
df.fillna('', inplace=True)
|
|
|
120 |
df = df.astype({'id': 'int32', 'text': 'string', 'label': 'category', 'metadata': 'string'})
|
121 |
+
|
122 |
parquet_filename = os.path.splitext(os.path.basename(file_path))[0] + '.parquet'
|
123 |
df.to_parquet(parquet_filename, engine='pyarrow', compression='snappy')
|
124 |
return f"{parquet_filename} ํ์ผ์ด ์ฑ๊ณต์ ์ผ๋ก ์
๋ก๋๋๊ณ ๋ณํ๋์์ต๋๋ค.", parquet_filename
|
|
|
127 |
|
128 |
def upload_parquet(file_path: str) -> Tuple[str, str, str]:
|
129 |
try:
|
|
|
130 |
df = pd.read_parquet(file_path, engine='pyarrow')
|
131 |
|
|
|
132 |
data_info = {
|
133 |
"์ด ๋ ์ฝ๋ ์": len(df),
|
134 |
"์ปฌ๋ผ ๋ชฉ๋ก": list(df.columns),
|
|
|
136 |
"๊ฒฐ์ธก์น ์ ๋ณด": df.isnull().sum().to_dict()
|
137 |
}
|
138 |
|
|
|
139 |
summary = []
|
140 |
summary.append(f"### ๋ฐ์ดํฐ์
๊ธฐ๋ณธ ์ ๋ณด:")
|
141 |
summary.append(f"- ์ด ๋ ์ฝ๋ ์: {data_info['์ด ๋ ์ฝ๋ ์']}")
|
142 |
summary.append(f"- ์ปฌ๋ผ ๋ชฉ๋ก: {', '.join(data_info['์ปฌ๋ผ ๋ชฉ๋ก'])}")
|
143 |
|
|
|
144 |
summary.append("\n### ์ปฌ๋ผ๋ณ ์ ๋ณด:")
|
145 |
for col in df.columns:
|
146 |
if df[col].dtype in ['int64', 'float64']:
|
|
|
147 |
stats = df[col].describe()
|
148 |
summary.append(f"\n{col} (์์นํ):")
|
149 |
summary.append(f"- ํ๊ท : {stats['mean']:.2f}")
|
150 |
summary.append(f"- ์ต์: {stats['min']}")
|
151 |
summary.append(f"- ์ต๋: {stats['max']}")
|
152 |
elif df[col].dtype == 'object' or df[col].dtype == 'string':
|
|
|
153 |
unique_count = df[col].nunique()
|
154 |
summary.append(f"\n{col} (ํ
์คํธ):")
|
155 |
summary.append(f"- ๊ณ ์ ๊ฐ ์: {unique_count}")
|
156 |
+
if unique_count < 10:
|
157 |
value_counts = df[col].value_counts().head(5)
|
158 |
summary.append("- ์์ 5๊ฐ ๊ฐ:")
|
159 |
for val, count in value_counts.items():
|
160 |
summary.append(f" โข {val}: {count}๊ฐ")
|
161 |
|
|
|
162 |
preview = df.head(10).to_markdown(index=False)
|
163 |
summary.append("\n### ๋ฐ์ดํฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ:")
|
164 |
summary.append(preview)
|
165 |
|
166 |
parquet_content = "\n".join(summary)
|
|
|
|
|
167 |
parquet_json = df.to_json(orient='records', force_ascii=False)
|
168 |
|
169 |
return "Parquet ํ์ผ์ด ์ฑ๊ณต์ ์ผ๋ก ์
๋ก๋๋์์ต๋๋ค.", parquet_content, parquet_json
|
170 |
except Exception as e:
|
171 |
return f"Parquet ํ์ผ ์
๋ก๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", "", ""
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
def text_to_parquet(text: str) -> Tuple[str, str, str]:
|
174 |
try:
|
|
|
175 |
lines = [line.strip() for line in text.split('\n') if line.strip()]
|
|
|
|
|
176 |
data = []
|
177 |
|
178 |
for line in lines:
|
179 |
try:
|
|
|
180 |
import re
|
181 |
pattern = r'(\d+),([^,]+),([^,]+),(.+)'
|
182 |
match = re.match(pattern, line)
|
183 |
|
184 |
if match:
|
185 |
id_val, text_val, label_val, metadata_val = match.groups()
|
|
|
|
|
186 |
text_val = text_val.strip().strip('"')
|
187 |
label_val = label_val.strip().strip('"')
|
188 |
metadata_val = metadata_val.strip().strip('"')
|
|
|
200 |
if not data:
|
201 |
return "๋ณํํ ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค.", "", ""
|
202 |
|
|
|
203 |
df = pd.DataFrame(data)
|
|
|
|
|
204 |
df = df.astype({
|
205 |
'id': 'int32',
|
206 |
'text': 'string',
|
|
|
208 |
'metadata': 'string'
|
209 |
})
|
210 |
|
|
|
211 |
parquet_filename = 'text_to_parquet.parquet'
|
212 |
df.to_parquet(parquet_filename, engine='pyarrow', compression='snappy')
|
|
|
|
|
213 |
preview = df.to_markdown(index=False)
|
214 |
|
215 |
return (
|
|
|
223 |
print(f"{error_message}\n{traceback.format_exc()}")
|
224 |
return error_message, "", ""
|
225 |
|
226 |
+
def respond(message: str, history: List[Dict[str, str]], system_message: str = "", max_tokens: int = 4000, temperature: float = 0.5, top_p: float = 0.9, parquet_data: str = None, api_key: str = None) -> str:
|
227 |
+
if not api_key:
|
228 |
+
yield "โ ๏ธ API Key๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. ์๋น์ค ์ด์ฉ์ ์ํด API Key๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
229 |
+
return
|
|
|
|
|
230 |
|
231 |
+
# OpenAI ํด๋ผ์ด์ธํธ ์ด๊ธฐํ
|
232 |
+
client = OpenAI(api_key=api_key)
|
233 |
+
|
234 |
+
system_prefix = """๋ฐ๋์ ํ๊ธ๋ก ๋ต๋ณํ ๊ฒ. ๋๋ ์
๋ก๋๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ง๋ฌธ์ ๋ต๋ณํ๋ ์ญํ ์ ํ๋ค.
|
235 |
+
|
236 |
+
์ฃผ์ ์ง์นจ:
|
237 |
+
1. ์ง๋ฌธ๊ณผ ์ง์ ๊ด๋ จ๋ ๋ด์ฉ๋ง ๊ฐ๋จ๋ช
๋ฃํ๊ฒ ๋ต๋ณํ ๊ฒ
|
238 |
+
2. ์ด์ ๋ต๋ณ๊ณผ ์ค๋ณต๋๋ ๋ด์ฉ์ ์ ์ธํ ๊ฒ
|
239 |
+
3. ๋ถํ์ํ ์์๋ ๋ถ์ฐ ์ค๋ช
์ ํ์ง ๋ง ๊ฒ
|
240 |
+
4. ๋์ผํ ๋ด์ฉ์ ๋ค๋ฅธ ํํ์ผ๋ก ๋ฐ๋ณตํ์ง ๋ง ๊ฒ
|
241 |
+
5. ํต์ฌ ์ ๋ณด๋ง ์ ๋ฌํ ๊ฒ
|
242 |
+
"""
|
243 |
+
|
244 |
+
if parquet_data:
|
245 |
+
try:
|
246 |
+
df = pd.read_json(io.StringIO(parquet_data))
|
247 |
+
data_summary = df.describe(include='all').to_string()
|
248 |
+
system_prefix += f"\n\n๋ฐ์ดํฐ ์์ฝ:\n{data_summary}"
|
249 |
+
except Exception as e:
|
250 |
+
print(f"๋ฐ์ดํฐ ๋ก๋ ์ค๋ฅ: {str(e)}")
|
251 |
+
|
252 |
+
messages = [{"role": "system", "content": system_prefix}]
|
253 |
+
recent_history = history[-3:] if history else []
|
254 |
+
for chat in recent_history:
|
255 |
+
messages.append({"role": chat["role"], "content": chat["content"]})
|
256 |
+
|
257 |
+
messages.append({"role": "user", "content": message})
|
258 |
|
259 |
try:
|
260 |
response = client.chat.completions.create(
|
261 |
model="gpt-4-0125-preview",
|
262 |
+
messages=messages,
|
263 |
+
max_tokens=max_tokens,
|
264 |
+
temperature=temperature,
|
265 |
+
top_p=top_p,
|
|
|
|
|
266 |
stream=True
|
267 |
)
|
268 |
|
|
|
270 |
for chunk in response:
|
271 |
if chunk.choices[0].delta.content:
|
272 |
full_response += chunk.choices[0].delta.content
|
273 |
+
yield clean_response(full_response)
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
except Exception as e:
|
276 |
+
error_message = f"์๋ต ์์ฑ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
277 |
+
print(f"{error_message}\n{traceback.format_exc()}")
|
278 |
+
yield error_message
|
279 |
+
|
280 |
+
def preprocess_text_with_llm(input_text: str, api_key: str = None) -> str:
|
281 |
+
if not api_key:
|
282 |
+
return "โ ๏ธ API Key๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. ์๋น์ค ์ด์ฉ์ ์ํด API Key๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
283 |
+
|
284 |
+
# OpenAI ํด๋ผ์ด์ธํธ ์ด๊ธฐํ
|
285 |
+
client = OpenAI(api_key=api_key)
|
286 |
|
287 |
system_prompt = """๋ฐ๋์ ํ๊ธ(ํ๊ตญ์ด)๋ก ๋ต๋ณํ์์ค. ๋น์ ์ ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ ์ ๋ฌธ๊ฐ์
๋๋ค. ์
๋ ฅ๋ ํ
์คํธ๋ฅผ CSV ๋ฐ์ดํฐ์
ํ์์ผ๋ก ๋ณํํ์ธ์.
|
288 |
|
|
|
300 |
|
301 |
try:
|
302 |
response = client.chat.completions.create(
|
303 |
+
model="gpt-4-0125-preview",
|
304 |
messages=[
|
305 |
{"role": "system", "content": system_prompt},
|
306 |
{"role": "user", "content": input_text}
|
|
|
315 |
if chunk.choices[0].delta.content:
|
316 |
full_response += chunk.choices[0].delta.content
|
317 |
|
|
|
318 |
processed_text = clean_response(full_response)
|
319 |
|
|
|
320 |
try:
|
321 |
from io import StringIO
|
322 |
import csv
|
|
|
330 |
print(error_message)
|
331 |
return error_message
|
332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
# Gradio Blocks ์ธํฐํ์ด์ค ์ค์
|
335 |
with gr.Blocks(css=css) as demo:
|
336 |
+
api_key_state = gr.State("") # API ํค๋ฅผ ์ ์ฅํ State ์ถ๊ฐ
|
337 |
+
|
338 |
gr.Markdown("# MyEzRAG: LLM์ด ๋๋ง์ ๋ฐ์ดํฐ๋ก ํ์ตํ ์ฝํ
์ธ ์์ฑ/๋ต๋ณ", elem_id="initial-description")
|
339 |
+
|
340 |
+
# API ํค ์
๋ ฅ ์น์
์ถ๊ฐ
|
341 |
+
with gr.Row(elem_classes="api-key-section"):
|
342 |
+
with gr.Column(scale=3):
|
343 |
+
api_key_input = gr.Textbox(
|
344 |
+
label="OpenAI API Key",
|
345 |
+
placeholder="sk-...",
|
346 |
+
type="password",
|
347 |
+
show_label=True
|
348 |
+
)
|
349 |
+
with gr.Column(scale=1):
|
350 |
+
api_key_button = gr.Button("API Key ์ค์ ", variant="primary")
|
351 |
+
|
352 |
+
# API ํค ์ํ ํ์
|
353 |
+
api_key_status = gr.Markdown("โ ๏ธ API Key๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. ์๋น์ค ์ด์ฉ์ ์ํด API Key๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.", elem_classes="api-key-status")
|
354 |
+
|
355 |
+
# API ํค ์ค์ ํจ์
|
356 |
+
def set_api_key(api_key: str):
|
357 |
+
if not api_key.strip():
|
358 |
+
return "โ ๏ธ API Key๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. ์๋น์ค ์ด์ฉ์ ์ํด API Key๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.", ""
|
359 |
+
if not api_key.startswith("sk-"):
|
360 |
+
return "โ ์ฌ๋ฐ๋ฅด์ง ์์ API Key ํ๏ฟฝ๏ฟฝ๏ฟฝ์
๋๋ค. ๋ค์ ํ์ธํด์ฃผ์ธ์.", ""
|
361 |
+
return "โ
API Key๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์ค์ ๋์์ต๋๋ค.", api_key
|
362 |
+
|
363 |
+
# API ํค ์ค์ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
364 |
+
api_key_button.click(
|
365 |
+
set_api_key,
|
366 |
+
inputs=[api_key_input],
|
367 |
+
outputs=[api_key_status, api_key_state]
|
368 |
+
)
|
369 |
+
|
370 |
gr.Markdown(
|
371 |
"### '์ฌ์ฉ ๋ฐฉ๋ฒ' ํญ์ ํตํด ์์ธํ ์ด์ฉ ๋ฐฉ๋ฒ์ ์ฐธ๊ณ ํ์ธ์.\n"
|
372 |
"### Tip) '์์ '๋ฅผ ํตํด ๋ค์ํ ํ์ฉ ๋ฐฉ๋ฒ์ ์ฒดํํ๊ณ ์์ฉํด ๋ณด์ธ์, ๋ฐ์ดํฐ์
์
๋ก๋์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ 10๊ฑด๋ง ์ถ๋ ฅ",
|
373 |
elem_id="initial-description"
|
374 |
)
|
375 |
|
376 |
+
# ์ฒซ ๋ฒ์งธ ํญ: My ๋ฐ์ดํฐ์
+LLM
|
|
|
|
|
377 |
with gr.Tab("My ๋ฐ์ดํฐ์
+LLM"):
|
378 |
gr.Markdown("### LLM๊ณผ ๋ํํ๊ธฐ")
|
379 |
chatbot_data_upload = gr.Chatbot(label="์ฑ๋ด", type="messages", elem_id="chatbot-data-upload")
|
|
|
388 |
|
389 |
parquet_data_state = gr.State()
|
390 |
|
391 |
+
def handle_message_data_upload(message: str, history: List[Dict[str, str]], system_message: str, max_tokens: int, temperature: float, top_p: float, parquet_data: str, api_key: str):
|
392 |
+
if not api_key:
|
393 |
+
history = history or []
|
394 |
+
history.append({"role": "assistant", "content": "โ ๏ธ API Key๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. ์๋น์ค ์ด์ฉ์ ์ํด API Key๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."})
|
395 |
+
yield history, ""
|
396 |
+
return
|
397 |
+
|
398 |
history = history or []
|
|
|
|
|
399 |
recent_questions = [chat['content'].strip().lower() for chat in history[-3:] if chat['role'] == 'user']
|
400 |
if message.strip().lower() in recent_questions:
|
401 |
yield history + [{"role": "assistant", "content": "๋์ผํ ์ง๋ฌธ์ด ์ต๊ทผ์ ์์์ต๋๋ค. ๋ค๋ฅธ ์ง๋ฌธ์ ํด์ฃผ์ธ์."}], ""
|
|
|
408 |
history,
|
409 |
system_message,
|
410 |
max_tokens,
|
411 |
+
temperature=0.3,
|
412 |
top_p=top_p,
|
413 |
+
parquet_data=parquet_data,
|
414 |
+
api_key=api_key
|
415 |
)
|
416 |
|
417 |
partial_response = ""
|
|
|
426 |
history.append({"role": "assistant", "content": response})
|
427 |
yield history, ""
|
428 |
|
|
|
|
|
|
|
429 |
send_data_upload.click(
|
430 |
handle_message_data_upload,
|
431 |
inputs=[
|
|
|
435 |
max_tokens,
|
436 |
temperature,
|
437 |
top_p,
|
438 |
+
parquet_data_state,
|
439 |
+
api_key_state,
|
440 |
],
|
441 |
outputs=[chatbot_data_upload, msg_data_upload],
|
442 |
queue=True
|
443 |
)
|
444 |
|
445 |
+
# ์์ ์ถ๊ฐ
|
446 |
with gr.Accordion("์์ ", open=False):
|
447 |
gr.Examples(
|
448 |
examples=[
|
|
|
457 |
label="์์ ์ ํ",
|
458 |
)
|
459 |
|
460 |
+
# Parquet ํ์ผ ์
๋ก๋
|
461 |
gr.Markdown("### Parquet ํ์ผ ์
๋ก๋")
|
462 |
with gr.Row():
|
463 |
with gr.Column():
|
|
|
481 |
outputs=[parquet_upload_status, parquet_preview_chat, parquet_data_state]
|
482 |
)
|
483 |
|
484 |
+
# ๋ ๋ฒ์งธ ํญ: CSV to My ๋ฐ์ดํฐ์
|
485 |
with gr.Tab("CSV to My ๋ฐ์ดํฐ์
"):
|
486 |
gr.Markdown("### CSV ํ์ผ ์
๋ก๋ ๋ฐ Parquet ๋ณํ")
|
487 |
with gr.Row():
|
|
|
506 |
outputs=[upload_status, parquet_preview, download_button]
|
507 |
)
|
508 |
|
509 |
+
# ์ธ ๋ฒ์งธ ํญ: Text to My ๋ฐ์ดํฐ์
|
510 |
with gr.Tab("Text to My ๋ฐ์ดํฐ์
"):
|
511 |
gr.Markdown("### ํ
์คํธ๋ฅผ ์
๋ ฅํ๋ฉด CSV๋ก ๋ณํ ํ Parquet์ผ๋ก ์๋ ์ ํ๋ฉ๋๋ค.")
|
512 |
with gr.Row():
|
|
|
534 |
outputs=[convert_status, parquet_preview_convert, download_parquet_convert]
|
535 |
)
|
536 |
|
537 |
+
# ๋ค ๋ฒ์งธ ํญ: Text Preprocessing with LLM
|
538 |
with gr.Tab("Text Preprocessing with LLM"):
|
539 |
gr.Markdown("### ํ
์คํธ๋ฅผ ์
๋ ฅํ๋ฉด LLM์ด ๋ฐ์ดํฐ์
ํ์์ ๋ง๊ฒ ์ ์ฒ๋ฆฌํ์ฌ ์ถ๋ ฅํฉ๋๋ค.")
|
540 |
with gr.Row():
|
|
|
561 |
interactive=False
|
562 |
)
|
563 |
|
|
|
564 |
convert_to_parquet_button = gr.Button("Parquet์ผ๋ก ๋ณํ")
|
565 |
download_parquet = gr.File(label="๋ณํ๋ Parquet ํ์ผ ๋ค์ด๋ก๋")
|
566 |
|
567 |
+
def handle_text_preprocessing(input_text: str, api_key: str):
|
568 |
+
if not api_key:
|
569 |
+
yield "โ ๏ธ API Key๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.", ""
|
570 |
+
return
|
571 |
+
|
572 |
if not input_text.strip():
|
573 |
+
yield "์
๋ ฅ ํ
์คํธ๊ฐ ์์ต๋๋ค.", ""
|
574 |
+
return
|
575 |
|
576 |
try:
|
577 |
+
yield "์ ์ฒ๋ฆฌ๋ฅผ ์์ํฉ๋๋ค...", ""
|
578 |
+
processed_text = preprocess_text_with_llm(input_text, api_key)
|
|
|
|
|
579 |
|
580 |
if processed_text:
|
581 |
+
yield "์ ์ฒ๋ฆฌ๊ฐ ์๋ฃ๋์์ต๋๋ค.", processed_text
|
|
|
582 |
else:
|
583 |
+
yield "์ ์ฒ๋ฆฌ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค.", ""
|
|
|
584 |
|
585 |
except Exception as e:
|
586 |
+
yield f"์ฒ๋ฆฌ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", ""
|
|
|
587 |
|
588 |
def clear_inputs():
|
589 |
return "", "๋๊ธฐ ์ค...", ""
|
|
|
600 |
except Exception as e:
|
601 |
return f"Parquet ๋ณํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}", None
|
602 |
|
|
|
603 |
preprocess_button.click(
|
604 |
handle_text_preprocessing,
|
605 |
+
inputs=[raw_text_input, api_key_state],
|
606 |
outputs=[preprocess_status, processed_text_output],
|
607 |
queue=True
|
608 |
)
|
|
|
618 |
outputs=[preprocess_status, download_parquet]
|
619 |
)
|
620 |
|
|
|
621 |
with gr.Accordion("์์ ํ
์คํธ", open=False):
|
622 |
gr.Examples(
|
623 |
examples=[
|
|
|
628 |
label="์์ ์ ํ"
|
629 |
)
|
630 |
|
631 |
+
# ์ฌ์ฉ ๋ฐฉ๋ฒ ํญ
|
632 |
with gr.Tab("๐ ์ฌ์ฉ ๋ฐฉ๋ฒ"):
|
633 |
gr.Markdown("""
|
634 |
# MyEzRAG ์ฌ์ฉ ๊ฐ์ด๋
|
635 |
|
636 |
+
## ๐ API Key ์ค์
|
637 |
+
1. OpenAI API Key๋ฅผ ์๋จ ์
๋ ฅ์ฐฝ์ ์
๋ ฅ
|
638 |
+
2. 'API Key ์ค์ ' ๋ฒํผ ํด๋ฆญ
|
639 |
+
3. ์ค์ ์ฑ๊ณต ๋ฉ์์ง ํ์ธ
|
640 |
+
|
641 |
## 1๏ธโฃ My ๋ฐ์ดํฐ์
+LLM ํญ
|
|
|
642 |
### ๊ธฐ๋ฅ
|
643 |
- ์
๋ก๋๋ Parquet ๋ฐ์ดํฐ์
์ ๊ธฐ๋ฐ์ผ๋ก LLM๊ณผ ๋ํ
|
644 |
- ๋ฐ์ดํฐ์
์ ๋ด์ฉ์ ํ์ฉํ ์ฝํ
์ธ ์์ฑ
|
|
|
655 |
---
|
656 |
|
657 |
## 2๏ธโฃ CSV to My ๋ฐ์ดํฐ์
ํญ
|
|
|
658 |
### ๊ธฐ๋ฅ
|
659 |
- CSV ํ์ผ์ Parquet ํ์์ผ๋ก ๋ณํ
|
660 |
- ๋ฐ์ดํฐ ์ต์ ํ ๋ฐ ์ ์
|
|
|
671 |
---
|
672 |
|
673 |
## 3๏ธโฃ Text to My ๋ฐ์ดํฐ์
ํญ
|
|
|
674 |
### ๊ธฐ๋ฅ
|
675 |
- ํ
์คํธ ํ์์ ๋ฐ์ดํฐ๋ฅผ Parquet์ผ๋ก ๋ณํ
|
676 |
- ์๋ ๋ฐ์ดํฐ ์
๋ ฅ ์ง์
|
|
|
693 |
---
|
694 |
|
695 |
## 4๏ธโฃ Text Preprocessing with LLM ํญ
|
|
|
696 |
### ๊ธฐ๋ฅ
|
697 |
- LLM์ ํ์ฉํ ์๋ ํ
์คํธ ์ ์ฒ๋ฆฌ
|
698 |
- ๊ตฌ์กฐํ๋ ๋ฐ์ดํฐ์
์์ฑ
|
|
|
709 |
- ๋ฐ์ดํฐ ์ ๊ทํ
|
710 |
|
711 |
## ๐ก ์ผ๋ฐ์ ์ธ ํ
|
712 |
+
- API Key๋ ์์ ํ๊ฒ ๋ณด๊ดํ๊ณ ์ฃผ๊ธฐ์ ์ผ๋ก ๊ฐฑ์
|
713 |
- ๊ฐ ํญ์ ์์ ๋ฅผ ์ฐธ๊ณ ํ์ฌ ์ฌ์ฉ๋ฒ ๏ฟฝ๏ฟฝํ๊ธฐ
|
714 |
- ๋ฐ์ดํฐ ํ์ง์ด ์ข์์๋ก ๋ ๋์ ๊ฒฐ๊ณผ ์ ๊ณต
|
715 |
- ์ค๋ฅ ๋ฐ์ ์ ์
๋ ฅ ๋ฐ์ดํฐ ํ์ ํ์ธ
|
716 |
- ๋์ฉ๋ ์ฒ๋ฆฌ ์ ์ ์ ํ ์ฒญํฌ ํฌ๊ธฐ๋ก ๋ถํ ์ฒ๋ฆฌ
|
717 |
|
718 |
## โ ๏ธ ์ฃผ์์ฌํญ
|
719 |
+
- API Key๋ฅผ ํ์ธ๊ณผ ๊ณต์ ํ์ง ์๊ธฐ
|
720 |
- ๋ฏผ๊ฐํ ๊ฐ์ธ์ ๋ณด ํฌํจํ์ง ์๊ธฐ
|
721 |
- ๋ฐ์ดํฐ ๋ฐฑ์
๊ถ์ฅ
|
722 |
- ๋คํธ์ํฌ ์ํ ํ์ธ
|
723 |
- ๋ธ๋ผ์ฐ์ ์บ์ ์ฃผ๊ธฐ์ ์ ๋ฆฌ
|
724 |
|
725 |
## ๐ ๋ฌธ์ ํด๊ฒฐ
|
726 |
+
- API Key ์ค๋ฅ: ํค ํ์ ๋ฐ ์ ํจ์ฑ ํ์ธ
|
727 |
- ์ค๋ฅ ๋ฐ์ ์ ์
๋ ฅ ๋ฐ์ดํฐ ํ์ ํ์ธ
|
728 |
- ํ์ผ ์
๋ก๋ ์คํจ ์ ํ์ผ ํฌ๊ธฐ ๋ฐ ํ์ ํ์ธ
|
729 |
- ๋ณํ ์คํจ ์ ๋ฐ์ดํฐ ์ธ์ฝ๋ฉ ํ์ธ
|
730 |
- ์๋ต์ด ๋๋ฆด ๊ฒฝ์ฐ ๋ฐ์ดํฐ ํฌ๊ธฐ ์กฐ์
|
731 |
""")
|
732 |
|
|
|
733 |
gr.Markdown("### [email protected]", elem_id="initial-description")
|
734 |
|
735 |
if __name__ == "__main__":
|
736 |
+
demo.launch(share=True)
|