cutechicken commited on
Commit
b03b509
โ€ข
1 Parent(s): ba10abd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +227 -112
app.py CHANGED
@@ -194,88 +194,7 @@ def read_uploaded_file(file):
194
 
195
 
196
 
197
- CSS = """
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
- # UI ๋ถ€๋ถ„ ์ˆ˜์ •
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  with gr.Blocks(css=CSS) as demo:
342
- with gr.Row():
343
- with gr.Column(scale=2):
344
- chatbot = gr.Chatbot(
345
- value=[],
346
- height=500,
347
- label="๋Œ€ํ™”์ฐฝ",
348
- show_label=True
 
 
 
 
 
 
 
 
349
  )
350
-
351
  msg = gr.Textbox(
352
- label="๋ฉ”์‹œ์ง€ ์ž…๋ ฅ",
353
  show_label=False,
354
- placeholder="๋ฌด์—‡์ด๋“  ๋ฌผ์–ด๋ณด์„ธ์š”... ๐Ÿ’ญ",
 
355
  container=False
356
  )
357
-
358
- with gr.Row():
359
- clear = gr.ClearButton([msg, chatbot], value="๋Œ€ํ™”๋‚ด์šฉ ์ง€์šฐ๊ธฐ")
360
- send = gr.Button("๋ณด๋‚ด๊ธฐ ๐Ÿ“ค")
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
- with gr.Accordion("๊ณ ๊ธ‰ ์„ค์ • โš™๏ธ", open=False):
371
- temperature = gr.Slider(minimum=0, maximum=1, step=0.1, value=0.8, label="์˜จ๋„")
372
- max_new_tokens = gr.Slider(minimum=128, maximum=8000, step=1, value=4000, label="์ตœ๋Œ€ ํ† ํฐ ์ˆ˜")
373
- top_p = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.8, label="์ƒ์œ„ ํ™•๋ฅ ")
374
- top_k = gr.Slider(minimum=1, maximum=20, step=1, value=20, label="์ƒ์œ„ K")
375
- penalty = gr.Slider(minimum=0.0, maximum=2.0, step=0.1, value=1.0, label="๋ฐ˜๋ณต ํŒจ๋„ํ‹ฐ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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