cutechicken commited on
Commit
7773cb1
โ€ข
1 Parent(s): 90e1e48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -90
app.py CHANGED
@@ -280,14 +280,6 @@ def read_uploaded_file(file):
280
  def init_msg():
281
  return "ํŒŒ์ผ์„ ๋ถ„์„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค..."
282
 
283
- file_upload.change(
284
- init_msg,
285
- outputs=msg
286
- ).then(
287
- stream_chat,
288
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
289
- outputs=[msg, chatbot]
290
- )
291
 
292
 
293
  @spaces.GPU
@@ -526,68 +518,67 @@ body {
526
  }
527
  """
528
 
529
- demo = gr.Blocks(css=CSS)
530
-
531
- with demo:
532
- with gr.Column():
533
- chatbot = gr.Chatbot(
534
- value=[],
535
- height=600,
536
- label="GiniGEN AI Assistant",
537
- elem_classes="chat-container"
538
- )
539
-
540
- with gr.Row(elem_classes="input-container"):
541
- with gr.Column(scale=1, min_width=70):
542
- file_upload = gr.File(
543
- type="filepath",
544
- elem_classes="file-upload-icon",
545
- scale=1,
546
- container=True,
547
- interactive=True,
548
- show_label=False
549
- )
550
 
551
- with gr.Column(scale=4):
552
- msg = gr.Textbox(
553
- show_label=False,
554
- placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”... ๐Ÿ’ญ",
555
- container=False,
556
- elem_classes="input-textbox",
557
- scale=1
558
- )
559
-
560
- with gr.Column(scale=1, min_width=70):
561
- send = gr.Button(
562
- "์ „์†ก",
563
- elem_classes="send-button custom-button",
564
- scale=1
565
- )
566
-
567
- with gr.Accordion("๐ŸŽฎ ๊ณ ๊ธ‰ ์„ค์ •", open=False):
568
- with gr.Row():
569
- with gr.Column(scale=1):
570
- temperature = gr.Slider(
571
- minimum=0, maximum=1, step=0.1, value=0.8,
572
- label="์ฐฝ์˜์„ฑ ์ˆ˜์ค€ ๐ŸŽจ"
573
- )
574
- max_new_tokens = gr.Slider(
575
- minimum=128, maximum=8000, step=1, value=4000,
576
- label="์ตœ๋Œ€ ํ† ํฐ ์ˆ˜ ๐Ÿ“"
577
- )
578
- with gr.Column(scale=1):
579
- top_p = gr.Slider(
580
- minimum=0.0, maximum=1.0, step=0.1, value=0.8,
581
- label="๋‹ค์–‘์„ฑ ์กฐ์ ˆ ๐ŸŽฏ"
582
  )
583
- top_k = gr.Slider(
584
- minimum=1, maximum=20, step=1, value=20,
585
- label="์„ ํƒ ๋ฒ”์œ„ ๐Ÿ“Š"
 
 
 
 
 
586
  )
587
- penalty = gr.Slider(
588
- minimum=0.0, maximum=2.0, step=0.1, value=1.0,
589
- label="๋ฐ˜๋ณต ์–ต์ œ ๐Ÿ”„"
 
 
 
590
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
 
592
 
593
  gr.Examples(
@@ -603,30 +594,30 @@ with demo:
603
  inputs=msg
604
  )
605
 
606
- # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
607
- def init_msg():
608
- return "ํŒŒ์ผ ๋ถ„์„์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค..."
609
-
610
- msg.submit(
611
- stream_chat,
612
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
613
- outputs=[msg, chatbot]
614
- )
615
-
616
- send.click(
617
- stream_chat,
618
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
619
- outputs=[msg, chatbot]
620
- )
621
-
622
- file_upload.change(
623
- init_msg,
624
- outputs=msg
625
- ).then(
626
- stream_chat,
627
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
628
- outputs=[msg, chatbot]
629
- )
630
 
631
  if __name__ == "__main__":
 
632
  demo.launch()
 
280
  def init_msg():
281
  return "ํŒŒ์ผ์„ ๋ถ„์„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค..."
282
 
 
 
 
 
 
 
 
 
283
 
284
 
285
  @spaces.GPU
 
518
  }
519
  """
520
 
521
+ def create_demo():
522
+ with gr.Blocks(css=CSS) as demo:
523
+ with gr.Column():
524
+ chatbot = gr.Chatbot(
525
+ value=[],
526
+ height=600,
527
+ label="GiniGEN AI Assistant",
528
+ elem_classes="chat-container"
529
+ )
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
+ with gr.Row(elem_classes="input-container"):
532
+ with gr.Column(scale=1, min_width=70):
533
+ file_upload = gr.File(
534
+ type="filepath",
535
+ elem_classes="file-upload-icon",
536
+ scale=1,
537
+ container=True,
538
+ interactive=True,
539
+ show_label=False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  )
541
+
542
+ with gr.Column(scale=4):
543
+ msg = gr.Textbox(
544
+ show_label=False,
545
+ placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”... ๐Ÿ’ญ",
546
+ container=False,
547
+ elem_classes="input-textbox",
548
+ scale=1
549
  )
550
+
551
+ with gr.Column(scale=1, min_width=70):
552
+ send = gr.Button(
553
+ "์ „์†ก",
554
+ elem_classes="send-button custom-button",
555
+ scale=1
556
  )
557
+
558
+ with gr.Accordion("๐ŸŽฎ ๊ณ ๊ธ‰ ์„ค์ •", open=False):
559
+ with gr.Row():
560
+ with gr.Column(scale=1):
561
+ temperature = gr.Slider(
562
+ minimum=0, maximum=1, step=0.1, value=0.8,
563
+ label="์ฐฝ์˜์„ฑ ์ˆ˜์ค€ ๐ŸŽจ"
564
+ )
565
+ max_new_tokens = gr.Slider(
566
+ minimum=128, maximum=8000, step=1, value=4000,
567
+ label="์ตœ๋Œ€ ํ† ํฐ ์ˆ˜ ๐Ÿ“"
568
+ )
569
+ with gr.Column(scale=1):
570
+ top_p = gr.Slider(
571
+ minimum=0.0, maximum=1.0, step=0.1, value=0.8,
572
+ label="๋‹ค์–‘์„ฑ ์กฐ์ ˆ ๐ŸŽฏ"
573
+ )
574
+ top_k = gr.Slider(
575
+ minimum=1, maximum=20, step=1, value=20,
576
+ label="์„ ํƒ ๋ฒ”์œ„ ๐Ÿ“Š"
577
+ )
578
+ penalty = gr.Slider(
579
+ minimum=0.0, maximum=2.0, step=0.1, value=1.0,
580
+ label="๋ฐ˜๋ณต ์–ต์ œ ๐Ÿ”„"
581
+ )
582
 
583
 
584
  gr.Examples(
 
594
  inputs=msg
595
  )
596
 
597
+ # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
598
+ msg.submit(
599
+ stream_chat,
600
+ inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
601
+ outputs=[msg, chatbot]
602
+ )
603
+
604
+ send.click(
605
+ stream_chat,
606
+ inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
607
+ outputs=[msg, chatbot]
608
+ )
609
+
610
+ file_upload.change(
611
+ init_msg,
612
+ outputs=msg
613
+ ).then(
614
+ stream_chat,
615
+ inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
616
+ outputs=[msg, chatbot]
617
+ )
618
+
619
+ return demo
 
620
 
621
  if __name__ == "__main__":
622
+ demo = create_demo()
623
  demo.launch()