Spaces:
Running
on
Zero
Running
on
Zero
cutechicken
commited on
Commit
โข
b03b509
1
Parent(s):
ba10abd
Update app.py
Browse files
app.py
CHANGED
@@ -194,88 +194,7 @@ def read_uploaded_file(file):
|
|
194 |
|
195 |
|
196 |
|
197 |
-
|
198 |
-
/* ์ ์ฒด ํ์ด์ง ์คํ์ผ๋ง */
|
199 |
-
body {
|
200 |
-
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
201 |
-
min-height: 100vh;
|
202 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
203 |
-
}
|
204 |
-
/* ๋ฉ์ธ ์ปจํ
์ด๋ */
|
205 |
-
.container {
|
206 |
-
max-width: 1200px;
|
207 |
-
margin: 0 auto;
|
208 |
-
padding: 2rem;
|
209 |
-
background: rgba(255, 255, 255, 0.95);
|
210 |
-
border-radius: 20px;
|
211 |
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
212 |
-
backdrop-filter: blur(10px);
|
213 |
-
transform: perspective(1000px) translateZ(0);
|
214 |
-
transition: all 0.3s ease;
|
215 |
-
}
|
216 |
-
/* ์ ๋ชฉ ์คํ์ผ๋ง */
|
217 |
-
h1 {
|
218 |
-
color: #2d3436;
|
219 |
-
font-size: 2.5rem;
|
220 |
-
text-align: center;
|
221 |
-
margin-bottom: 2rem;
|
222 |
-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
|
223 |
-
transform: perspective(1000px) translateZ(20px);
|
224 |
-
}
|
225 |
-
h3 {
|
226 |
-
text-align: center;
|
227 |
-
color: #2d3436;
|
228 |
-
font-size: 1.5rem;
|
229 |
-
margin: 1rem 0;
|
230 |
-
}
|
231 |
-
/* ์ฑํ
๋ฐ์ค ์คํ์ผ๋ง */
|
232 |
-
.chatbox {
|
233 |
-
background: white;
|
234 |
-
border-radius: 15px;
|
235 |
-
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
|
236 |
-
backdrop-filter: blur(4px);
|
237 |
-
border: 1px solid rgba(255, 255, 255, 0.18);
|
238 |
-
padding: 1rem;
|
239 |
-
margin: 1rem 0;
|
240 |
-
transform: translateZ(0);
|
241 |
-
transition: all 0.3s ease;
|
242 |
-
}
|
243 |
-
/* ๋ฉ์์ง ์คํ์ผ๋ง */
|
244 |
-
.chatbox .messages .message.user {
|
245 |
-
background: linear-gradient(145deg, #e1f5fe, #bbdefb);
|
246 |
-
border-radius: 15px;
|
247 |
-
padding: 1rem;
|
248 |
-
margin: 0.5rem;
|
249 |
-
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.05);
|
250 |
-
transform: translateZ(10px);
|
251 |
-
animation: messageIn 0.3s ease-out;
|
252 |
-
}
|
253 |
-
.chatbox .messages .message.bot {
|
254 |
-
background: linear-gradient(145deg, #f5f5f5, #eeeeee);
|
255 |
-
border-radius: 15px;
|
256 |
-
padding: 1rem;
|
257 |
-
margin: 0.5rem;
|
258 |
-
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.05);
|
259 |
-
transform: translateZ(10px);
|
260 |
-
animation: messageIn 0.3s ease-out;
|
261 |
-
}
|
262 |
-
/* ๋ฒํผ ์คํ์ผ๋ง */
|
263 |
-
.duplicate-button {
|
264 |
-
background: linear-gradient(145deg, #24292e, #1a1e22) !important;
|
265 |
-
color: white !important;
|
266 |
-
border-radius: 100vh !important;
|
267 |
-
padding: 0.8rem 1.5rem !important;
|
268 |
-
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2) !important;
|
269 |
-
transition: all 0.3s ease !important;
|
270 |
-
border: none !important;
|
271 |
-
cursor: pointer !important;
|
272 |
-
}
|
273 |
-
.duplicate-button:hover {
|
274 |
-
transform: translateY(-2px) !important;
|
275 |
-
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
|
276 |
-
}
|
277 |
-
/* ์
๋ ฅ ํ๋ ์คํ์ผ๋ง */
|
278 |
-
"""
|
279 |
|
280 |
@spaces.GPU
|
281 |
def stream_chat(message: str, history: list, uploaded_file, temperature: float, max_new_tokens: int, top_p: float, top_k: int, penalty: float):
|
@@ -337,42 +256,239 @@ def stream_chat(message: str, history: list, uploaded_file, temperature: float,
|
|
337 |
error_message = f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
338 |
yield "", history + [[message, error_message]]
|
339 |
|
340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
with gr.Blocks(css=CSS) as demo:
|
342 |
-
with gr.
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
)
|
350 |
-
|
351 |
msg = gr.Textbox(
|
352 |
-
label="๋ฉ์์ง ์
๋ ฅ",
|
353 |
show_label=False,
|
354 |
-
placeholder="
|
|
|
355 |
container=False
|
356 |
)
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
with gr.Column(scale=1):
|
363 |
-
gr.Markdown("### ํ์ผ ์
๋ก๋ ๐")
|
364 |
-
file_upload = gr.File(
|
365 |
-
label="ํ์ผ ์ ํ",
|
366 |
-
file_types=["text", ".csv", ".parquet"],
|
367 |
-
type="filepath"
|
368 |
)
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
|
378 |
msg.submit(
|
@@ -390,7 +506,6 @@ with gr.Blocks(css=CSS) as demo:
|
|
390 |
def init_msg():
|
391 |
return "ํ์ผ ๋ถ์์ ์์ํฉ๋๋ค..."
|
392 |
|
393 |
-
# ํ์ผ ์
๋ก๋์ ์๋ ๋ถ์
|
394 |
file_upload.change(
|
395 |
init_msg,
|
396 |
outputs=msg
|
|
|
194 |
|
195 |
|
196 |
|
197 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
@spaces.GPU
|
200 |
def stream_chat(message: str, history: list, uploaded_file, temperature: float, max_new_tokens: int, top_p: float, top_k: int, penalty: float):
|
|
|
256 |
error_message = f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
257 |
yield "", history + [[message, error_message]]
|
258 |
|
259 |
+
CSS = """
|
260 |
+
/* 3D ์คํ์ผ CSS */
|
261 |
+
:root {
|
262 |
+
--primary-color: #2196f3;
|
263 |
+
--secondary-color: #1976d2;
|
264 |
+
--background-color: #f0f2f5;
|
265 |
+
--card-background: #ffffff;
|
266 |
+
--text-color: #333333;
|
267 |
+
--shadow-color: rgba(0, 0, 0, 0.1);
|
268 |
+
}
|
269 |
+
|
270 |
+
body {
|
271 |
+
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
272 |
+
min-height: 100vh;
|
273 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
274 |
+
}
|
275 |
+
|
276 |
+
.container {
|
277 |
+
transform-style: preserve-3d;
|
278 |
+
perspective: 1000px;
|
279 |
+
}
|
280 |
+
|
281 |
+
.chatbot {
|
282 |
+
background: var(--card-background);
|
283 |
+
border-radius: 20px;
|
284 |
+
box-shadow:
|
285 |
+
0 10px 20px var(--shadow-color),
|
286 |
+
0 6px 6px var(--shadow-color);
|
287 |
+
transform: translateZ(0);
|
288 |
+
transition: transform 0.3s ease;
|
289 |
+
backdrop-filter: blur(10px);
|
290 |
+
}
|
291 |
+
|
292 |
+
.chatbot:hover {
|
293 |
+
transform: translateZ(10px);
|
294 |
+
}
|
295 |
+
|
296 |
+
/* ๋ฉ์์ง ์
๋ ฅ ์์ญ */
|
297 |
+
.input-area {
|
298 |
+
background: var(--card-background);
|
299 |
+
border-radius: 15px;
|
300 |
+
padding: 15px;
|
301 |
+
margin-top: 20px;
|
302 |
+
box-shadow:
|
303 |
+
0 5px 15px var(--shadow-color),
|
304 |
+
0 3px 3px var(--shadow-color);
|
305 |
+
transform: translateZ(0);
|
306 |
+
transition: all 0.3s ease;
|
307 |
+
display: flex;
|
308 |
+
align-items: center;
|
309 |
+
gap: 10px;
|
310 |
+
}
|
311 |
+
|
312 |
+
.input-area:hover {
|
313 |
+
transform: translateZ(5px);
|
314 |
+
}
|
315 |
+
|
316 |
+
/* ๋ฒํผ ์คํ์ผ */
|
317 |
+
.custom-button {
|
318 |
+
background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
|
319 |
+
color: white;
|
320 |
+
border: none;
|
321 |
+
border-radius: 10px;
|
322 |
+
padding: 10px 20px;
|
323 |
+
font-weight: 600;
|
324 |
+
cursor: pointer;
|
325 |
+
transform: translateZ(0);
|
326 |
+
transition: all 0.3s ease;
|
327 |
+
box-shadow:
|
328 |
+
0 4px 6px var(--shadow-color),
|
329 |
+
0 1px 3px var(--shadow-color);
|
330 |
+
}
|
331 |
+
|
332 |
+
.custom-button:hover {
|
333 |
+
transform: translateZ(5px) translateY(-2px);
|
334 |
+
box-shadow:
|
335 |
+
0 7px 14px var(--shadow-color),
|
336 |
+
0 3px 6px var(--shadow-color);
|
337 |
+
}
|
338 |
+
|
339 |
+
/* ํ์ผ ์
๋ก๋ ๋ฒํผ */
|
340 |
+
.file-upload-button {
|
341 |
+
background: linear-gradient(145deg, #64b5f6, #42a5f5);
|
342 |
+
color: white;
|
343 |
+
border: none;
|
344 |
+
border-radius: 10px;
|
345 |
+
padding: 8px 15px;
|
346 |
+
margin-right: 10px;
|
347 |
+
cursor: pointer;
|
348 |
+
transform: translateZ(0);
|
349 |
+
transition: all 0.3s ease;
|
350 |
+
}
|
351 |
+
|
352 |
+
.file-upload-button:hover {
|
353 |
+
transform: translateZ(5px) translateY(-2px);
|
354 |
+
}
|
355 |
+
|
356 |
+
/* ๋ฉ์์ง ์คํ์ผ */
|
357 |
+
.message {
|
358 |
+
background: var(--card-background);
|
359 |
+
border-radius: 15px;
|
360 |
+
padding: 15px;
|
361 |
+
margin: 10px 0;
|
362 |
+
box-shadow:
|
363 |
+
0 4px 6px var(--shadow-color),
|
364 |
+
0 1px 3px var(--shadow-color);
|
365 |
+
transform: translateZ(0);
|
366 |
+
transition: all 0.3s ease;
|
367 |
+
}
|
368 |
+
|
369 |
+
.message:hover {
|
370 |
+
transform: translateZ(5px);
|
371 |
+
}
|
372 |
+
|
373 |
+
/* ์ค์ ํจ๋ */
|
374 |
+
.settings-panel {
|
375 |
+
background: var(--card-background);
|
376 |
+
border-radius: 15px;
|
377 |
+
padding: 15px;
|
378 |
+
margin-top: 20px;
|
379 |
+
box-shadow:
|
380 |
+
0 5px 15px var(--shadow-color),
|
381 |
+
0 3px 3px var(--shadow-color);
|
382 |
+
transform: translateZ(0);
|
383 |
+
transition: all 0.3s ease;
|
384 |
+
}
|
385 |
+
|
386 |
+
.settings-panel:hover {
|
387 |
+
transform: translateZ(5px);
|
388 |
+
}
|
389 |
+
|
390 |
+
/* ์ฌ๋ผ์ด๋ ์คํ์ผ */
|
391 |
+
.slider-container {
|
392 |
+
margin: 10px 0;
|
393 |
+
}
|
394 |
+
|
395 |
+
.slider {
|
396 |
+
-webkit-appearance: none;
|
397 |
+
width: 100%;
|
398 |
+
height: 5px;
|
399 |
+
border-radius: 5px;
|
400 |
+
background: #ddd;
|
401 |
+
outline: none;
|
402 |
+
}
|
403 |
+
|
404 |
+
.slider::-webkit-slider-thumb {
|
405 |
+
-webkit-appearance: none;
|
406 |
+
appearance: none;
|
407 |
+
width: 15px;
|
408 |
+
height: 15px;
|
409 |
+
border-radius: 50%;
|
410 |
+
background: var(--primary-color);
|
411 |
+
cursor: pointer;
|
412 |
+
transition: all 0.3s ease;
|
413 |
+
}
|
414 |
+
|
415 |
+
.slider::-webkit-slider-thumb:hover {
|
416 |
+
transform: scale(1.2);
|
417 |
+
}
|
418 |
+
"""
|
419 |
+
|
420 |
+
# UI ๊ตฌ์ฑ ์์
|
421 |
with gr.Blocks(css=CSS) as demo:
|
422 |
+
with gr.Column():
|
423 |
+
chatbot = gr.Chatbot(
|
424 |
+
value=[],
|
425 |
+
height=500,
|
426 |
+
label="GiniGEN AI Assistant",
|
427 |
+
elem_classes="chatbot"
|
428 |
+
)
|
429 |
+
|
430 |
+
with gr.Row(elem_classes="input-area"):
|
431 |
+
file_upload = gr.File(
|
432 |
+
label="๐ ํ์ผ ์ฒจ๋ถ",
|
433 |
+
type="filepath",
|
434 |
+
scale=0.15,
|
435 |
+
min_width=50,
|
436 |
+
elem_classes="file-upload-button"
|
437 |
)
|
|
|
438 |
msg = gr.Textbox(
|
|
|
439 |
show_label=False,
|
440 |
+
placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์... ๐ญ",
|
441 |
+
scale=0.7,
|
442 |
container=False
|
443 |
)
|
444 |
+
send = gr.Button(
|
445 |
+
"์ ์ก",
|
446 |
+
scale=0.15,
|
447 |
+
min_width=50,
|
448 |
+
elem_classes="custom-button"
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
)
|
450 |
+
|
451 |
+
with gr.Accordion("๐ฎ ๊ณ ๊ธ ์ค์ ", open=False, elem_classes="settings-panel"):
|
452 |
+
with gr.Row():
|
453 |
+
with gr.Column(scale=1):
|
454 |
+
temperature = gr.Slider(
|
455 |
+
minimum=0, maximum=1, step=0.1, value=0.8,
|
456 |
+
label="์ฐฝ์์ฑ ์์ค ๐จ",
|
457 |
+
elem_classes="slider"
|
458 |
+
)
|
459 |
+
max_new_tokens = gr.Slider(
|
460 |
+
minimum=128, maximum=8000, step=1, value=4000,
|
461 |
+
label="์ต๋ ํ ํฐ ์ ๐",
|
462 |
+
elem_classes="slider"
|
463 |
+
)
|
464 |
+
with gr.Column(scale=1):
|
465 |
+
top_p = gr.Slider(
|
466 |
+
minimum=0.0, maximum=1.0, step=0.1, value=0.8,
|
467 |
+
label="๋ค์์ฑ ์กฐ์ ๐ฏ",
|
468 |
+
elem_classes="slider"
|
469 |
+
)
|
470 |
+
top_k = gr.Slider(
|
471 |
+
minimum=1, maximum=20, step=1, value=20,
|
472 |
+
label="์ ํ ๋ฒ์ ๐",
|
473 |
+
elem_classes="slider"
|
474 |
+
)
|
475 |
+
penalty = gr.Slider(
|
476 |
+
minimum=0.0, maximum=2.0, step=0.1, value=1.0,
|
477 |
+
label="๋ฐ๋ณต ์ต์ ๐",
|
478 |
+
elem_classes="slider"
|
479 |
+
)
|
480 |
+
|
481 |
+
gr.Examples(
|
482 |
+
examples=[
|
483 |
+
["ํ๊ตญ์ ์ ํต ์ ๊ธฐ์ 24์ ๊ธฐ์ ๋ํด ์์ธํ ์ค๋ช
ํด์ฃผ์ธ์."],
|
484 |
+
["์ฐ๋ฆฌ๋๋ผ ์ ํต ์์ ์ค ๊ฑด๊ฐ์ ์ข์ ๋ฐํจ์์ 5๊ฐ์ง๋ฅผ ์ถ์ฒํ๊ณ ๊ทธ ํจ๋ฅ์ ์ค๋ช
ํด์ฃผ์ธ์."],
|
485 |
+
["ํ๊ตญ์ ๋ํ์ ์ธ ์ฐ๋ค์ ์๊ฐํ๊ณ , ๊ฐ ์ฐ์ ํน์ง๊ณผ ๋ฑ์ฐ ์ฝ์ค๋ฅผ ์ถ์ฒํด์ฃผ์ธ์."],
|
486 |
+
["์ฌ๋ฌผ๋์ด์ ์
๊ธฐ ๊ตฌ์ฑ๊ณผ ์ฅ๋จ์ ๋ํด ์ด๋ณด์๋ ์ดํดํ๊ธฐ ์ฝ๊ฒ ์ค๋ช
ํด์ฃผ์ธ์."],
|
487 |
+
["ํ๊ตญ์ ์ ํต ๊ฑด์ถ๋ฌผ์ ๋ด๊ธด ๊ณผํ์ ์๋ฆฌ๋ฅผ ํ๋์ ๊ด์ ์์ ๋ถ์ํด์ฃผ์ธ์."],
|
488 |
+
],
|
489 |
+
inputs=msg,
|
490 |
+
elem_classes="examples-panel"
|
491 |
+
)
|
492 |
|
493 |
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
|
494 |
msg.submit(
|
|
|
506 |
def init_msg():
|
507 |
return "ํ์ผ ๋ถ์์ ์์ํฉ๋๋ค..."
|
508 |
|
|
|
509 |
file_upload.change(
|
510 |
init_msg,
|
511 |
outputs=msg
|