cutechicken commited on
Commit
c53bcba
โ€ข
1 Parent(s): e468070

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -99
app.py CHANGED
@@ -533,44 +533,90 @@ def stream_chat(message: str, history: list, uploaded_file, temperature: float,
533
 
534
  def create_demo():
535
  with gr.Blocks(css=CSS) as demo:
536
- with gr.Column():
537
- chatbot = gr.Chatbot(
538
- value=[],
539
- height=600,
540
- label="GiniGEN AI Assistant",
541
- elem_classes="chat-container"
542
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
 
544
- with gr.Row(elem_classes="input-container"):
545
- with gr.Column(scale=1, min_width=70):
546
- file_upload = gr.File(
547
- type="filepath",
548
- elem_classes="file-upload-icon",
549
- scale=1,
550
- container=True,
551
- interactive=True,
552
- show_label=False
 
 
 
 
 
 
 
 
553
  )
554
-
555
- with gr.Column(scale=4):
556
- msg = gr.Textbox(
557
- show_label=False,
558
- placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”... ๐Ÿ’ญ",
559
- container=False,
560
- elem_classes="input-textbox",
561
- scale=1
562
  )
563
-
564
- with gr.Column(scale=1, min_width=70):
565
- send = gr.Button(
566
- "์ „์†ก",
567
- elem_classes="send-button custom-button",
568
- scale=1
569
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
570
 
571
- # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ ์ˆ˜์ •
572
- def init_msg():
573
- return "ํŒŒ์ผ์„ ๋ถ„์„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค..."
 
 
574
 
575
  file_upload.change(
576
  fn=init_msg,
@@ -583,72 +629,6 @@ def create_demo():
583
  queue=True
584
  )
585
 
586
-
587
-
588
- with gr.Accordion("๐ŸŽฎ ๊ณ ๊ธ‰ ์„ค์ •", open=False):
589
- with gr.Row():
590
- with gr.Column(scale=1):
591
- temperature = gr.Slider(
592
- minimum=0, maximum=1, step=0.1, value=0.8,
593
- label="์ฐฝ์˜์„ฑ ์ˆ˜์ค€ ๐ŸŽจ"
594
- )
595
- max_new_tokens = gr.Slider(
596
- minimum=128, maximum=8000, step=1, value=4000,
597
- label="์ตœ๋Œ€ ํ† ํฐ ์ˆ˜ ๐Ÿ“"
598
- )
599
- with gr.Column(scale=1):
600
- top_p = gr.Slider(
601
- minimum=0.0, maximum=1.0, step=0.1, value=0.8,
602
- label="๋‹ค์–‘์„ฑ ์กฐ์ ˆ ๐ŸŽฏ"
603
- )
604
- top_k = gr.Slider(
605
- minimum=1, maximum=20, step=1, value=20,
606
- label="์„ ํƒ ๋ฒ”์œ„ ๐Ÿ“Š"
607
- )
608
- penalty = gr.Slider(
609
- minimum=0.0, maximum=2.0, step=0.1, value=1.0,
610
- label="๋ฐ˜๋ณต ์–ต์ œ ๐Ÿ”„"
611
- )
612
-
613
-
614
-
615
-
616
- # Examples ์œ„์น˜ ์ˆ˜์ •
617
- gr.Examples(
618
- examples=[
619
- ["๋‹ค์Œ ์ฝ”๋“œ์˜ ๋ฌธ์ œ์ ์„ ์ฐพ์•„๋‚ด๊ณ  ๊ฐœ์„ ๋œ ๋ฒ„์ „์„ ์ œ์‹œํ•ด์ฃผ์„ธ์š”:\ndef fibonacci(n):\n if n <= 1: return n\n return fibonacci(n-1) + fibonacci(n-2)"],
620
- ["๋‹ค์Œ ์˜์–ด ๋ฌธ์žฅ์„ ํ•œ๊ตญ์–ด๋กœ ๋ฒˆ์—ญํ•˜๊ณ , ์–ดํœ˜์™€ ๋ฌธ๋ฒ•์  ํŠน์ง•์„ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”: 'The implementation of artificial intelligence in healthcare has revolutionized patient care, yet it raises ethical concerns regarding privacy and decision-making autonomy.'"],
621
- ["์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„์„ํ•˜๊ณ  ์ธ์‚ฌ์ดํŠธ๋ฅผ ๋„์ถœํ•ด์ฃผ์„ธ์š”:\n์—ฐ๋„๋ณ„ ๋งค์ถœ์•ก(์–ต์›)\n2019: 1200\n2020: 980\n2021: 1450\n2022: 2100\n2023: 1890"],
622
- ["๋‹ค์Œ ์‹œ๋‚˜๋ฆฌ์˜ค์— ๋Œ€ํ•œ SWOT ๋ถ„์„์„ ํ•ด์ฃผ์„ธ์š”: '์ „ํ†ต์ ์ธ ์˜คํ”„๋ผ์ธ ์„œ์ ์ด ์˜จ๋ผ์ธ ํ”Œ๋žซํผ์œผ๋กœ์˜ ์ „ํ™˜์„ ๊ณ ๋ ค์ค‘์ž…๋‹ˆ๋‹ค. ๋…์ž๋“ค์˜ ๋””์ง€ํ„ธ ์ฝ˜ํ…์ธ  ์†Œ๋น„๊ฐ€ ์ฆ๊ฐ€ํ•˜๋Š” ์ƒํ™ฉ์—์„œ ๊ฒฝ์Ÿ๋ ฅ์„ ์œ ์ง€ํ•˜๋ฉด์„œ ๊ธฐ์กด ๊ณ ๊ฐ์ธต๋„ ์ง€ํ‚ค๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.'"],
623
- ["๋‹ค์Œ ์ˆ˜ํ•™ ๋ฌธ์ œ๋ฅผ ๋‹จ๊ณ„๋ณ„๋กœ ์ž์„ธํžˆ ํ’€์ดํ•ด์ฃผ์„ธ์š”: 'ํ•œ ์›์˜ ๋„“์ด๊ฐ€ ๊ทธ ์›์— ๋‚ด์ ‘ํ•˜๋Š” ์ •์‚ฌ๊ฐํ˜• ๋„“์ด์˜ 2๋ฐฐ์ผ ๋•Œ, ์›์˜ ๋ฐ˜์ง€๋ฆ„๊ณผ ์ •์‚ฌ๊ฐํ˜•์˜ ํ•œ ๋ณ€์˜ ๊ธธ์ด์˜ ๊ด€๊ณ„๋ฅผ ๊ตฌํ•˜์‹œ์˜ค.'"],
624
- ["๋‹ค์Œ SQL ์ฟผ๋ฆฌ๋ฅผ ์ตœ์ ํ™”ํ•˜๊ณ  ๊ฐœ์„ ์ ์„ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”:\nSELECT * FROM orders o\nLEFT JOIN customers c ON o.customer_id = c.id\nWHERE YEAR(o.order_date) = 2023\nAND c.country = 'Korea'\nORDER BY o.order_date DESC;"],
625
- ["๋‹ค์Œ ๋งˆ์ผ€ํŒ… ์บ ํŽ˜์ธ์˜ ROI๋ฅผ ๋ถ„์„ํ•˜๊ณ  ๊ฐœ์„ ๋ฐฉ์•ˆ์„ ์ œ์‹œํ•ด์ฃผ์„ธ์š”:\n์ด ๋น„์šฉ: 5000๋งŒ์›\n๋„๋‹ฌ์ž ์ˆ˜: 100๋งŒ๋ช…\nํด๋ฆญ๋ฅ : 2.3%\n์ „ํ™˜์œจ: 0.8%\nํ‰๊ท  ๊ตฌ๋งค์•ก: 35,000์›"],
626
- ],
627
- inputs=msg
628
- )
629
-
630
- # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
631
- msg.submit(
632
- stream_chat,
633
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
634
- outputs=[msg, chatbot]
635
- )
636
-
637
- send.click(
638
- stream_chat,
639
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
640
- outputs=[msg, chatbot]
641
- )
642
-
643
- file_upload.change(
644
- init_msg,
645
- outputs=msg
646
- ).then(
647
- stream_chat,
648
- inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
649
- outputs=[msg, chatbot]
650
- )
651
-
652
  return demo
653
 
654
  if __name__ == "__main__":
 
533
 
534
  def create_demo():
535
  with gr.Blocks(css=CSS) as demo:
536
+ chatbot = gr.Chatbot(
537
+ value=[],
538
+ height=600,
539
+ label="GiniGEN AI Assistant",
540
+ elem_classes="chat-container"
541
+ )
542
+
543
+ with gr.Row(elem_classes="input-container"):
544
+ with gr.Column(scale=1, min_width=70):
545
+ file_upload = gr.File(
546
+ type="filepath",
547
+ elem_classes="file-upload-icon",
548
+ scale=1,
549
+ container=True,
550
+ interactive=True,
551
+ show_label=False
552
+ )
553
+
554
+ with gr.Column(scale=4):
555
+ msg = gr.Textbox(
556
+ show_label=False,
557
+ placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”... ๐Ÿ’ญ",
558
+ container=False,
559
+ elem_classes="input-textbox",
560
+ scale=1
561
+ )
562
 
563
+ with gr.Column(scale=1, min_width=70):
564
+ send = gr.Button(
565
+ "์ „์†ก",
566
+ elem_classes="send-button custom-button",
567
+ scale=1
568
+ )
569
+
570
+ with gr.Accordion("๐ŸŽฎ ๊ณ ๊ธ‰ ์„ค์ •", open=False):
571
+ with gr.Row():
572
+ with gr.Column(scale=1):
573
+ temperature = gr.Slider(
574
+ minimum=0, maximum=1, step=0.1, value=0.8,
575
+ label="์ฐฝ์˜์„ฑ ์ˆ˜์ค€ ๐ŸŽจ"
576
+ )
577
+ max_new_tokens = gr.Slider(
578
+ minimum=128, maximum=8000, step=1, value=4000,
579
+ label="์ตœ๋Œ€ ํ† ํฐ ์ˆ˜ ๐Ÿ“"
580
  )
581
+ with gr.Column(scale=1):
582
+ top_p = gr.Slider(
583
+ minimum=0.0, maximum=1.0, step=0.1, value=0.8,
584
+ label="๋‹ค์–‘์„ฑ ์กฐ์ ˆ ๐ŸŽฏ"
 
 
 
 
585
  )
586
+ top_k = gr.Slider(
587
+ minimum=1, maximum=20, step=1, value=20,
588
+ label="์„ ํƒ ๋ฒ”์œ„ ๐Ÿ“Š"
 
 
 
589
  )
590
+ penalty = gr.Slider(
591
+ minimum=0.0, maximum=2.0, step=0.1, value=1.0,
592
+ label="๋ฐ˜๋ณต ์–ต์ œ ๐Ÿ”„"
593
+ )
594
+
595
+ gr.Examples(
596
+ examples=[
597
+ ["๋‹ค์Œ ์ฝ”๋“œ์˜ ๋ฌธ์ œ์ ์„ ์ฐพ์•„๋‚ด๊ณ  ๊ฐœ์„ ๋œ ๋ฒ„์ „์„ ์ œ์‹œํ•ด์ฃผ์„ธ์š”:\ndef fibonacci(n):\n if n <= 1: return n\n return fibonacci(n-1) + fibonacci(n-2)"],
598
+ ["๋‹ค์Œ ์˜์–ด ๋ฌธ์žฅ์„ ํ•œ๊ตญ์–ด๋กœ ๋ฒˆ์—ญํ•˜๊ณ , ์–ดํœ˜์™€ ๋ฌธ๋ฒ•์  ํŠน์ง•์„ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”: 'The implementation of artificial intelligence in healthcare has revolutionized patient care, yet it raises ethical concerns regarding privacy and decision-making autonomy.'"],
599
+ ["์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„์„ํ•˜๊ณ  ์ธ์‚ฌ์ดํŠธ๋ฅผ ๋„์ถœํ•ด์ฃผ์„ธ์š”:\n์—ฐ๋„๋ณ„ ๋งค์ถœ์•ก(์–ต์›)\n2019: 1200\n2020: 980\n2021: 1450\n2022: 2100\n2023: 1890"],
600
+ ["๋‹ค์Œ ์‹œ๋‚˜๋ฆฌ์˜ค์— ๋Œ€ํ•œ SWOT ๋ถ„์„์„ ํ•ด์ฃผ์„ธ์š”: '์ „ํ†ต์ ์ธ ์˜คํ”„๋ผ์ธ ์„œ์ ์ด ์˜จ๋ผ์ธ ํ”Œ๋žซํผ์œผ๋กœ์˜ ์ „ํ™˜์„ ๊ณ ๋ ค์ค‘์ž…๋‹ˆ๋‹ค. ๋…์ž๋“ค์˜ ๋””์ง€ํ„ธ ์ฝ˜ํ…์ธ  ์†Œ๋น„๊ฐ€ ์ฆ๊ฐ€ํ•˜๋Š” ์ƒํ™ฉ์—์„œ ๊ฒฝ์Ÿ๋ ฅ์„ ์œ ์ง€ํ•˜๋ฉด์„œ ๊ธฐ์กด ๊ณ ๊ฐ์ธต๋„ ์ง€ํ‚ค๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.'"],
601
+ ["๋‹ค์Œ ์ˆ˜ํ•™ ๋ฌธ์ œ๋ฅผ ๋‹จ๊ณ„๋ณ„๋กœ ์ž์„ธํžˆ ํ’€์ดํ•ด์ฃผ์„ธ์š”: 'ํ•œ ์›์˜ ๋„“์ด๊ฐ€ ๊ทธ ์›์— ๋‚ด์ ‘ํ•˜๋Š” ์ •์‚ฌ๊ฐํ˜• ๋„“์ด์˜ 2๋ฐฐ์ผ ๋•Œ, ์›์˜ ๋ฐ˜์ง€๋ฆ„๊ณผ ์ •์‚ฌ๊ฐํ˜•์˜ ํ•œ ๋ณ€์˜ ๊ธธ์ด์˜ ๊ด€๊ณ„๋ฅผ ๊ตฌํ•˜์‹œ์˜ค.'"],
602
+ ["๋‹ค์Œ SQL ์ฟผ๋ฆฌ๋ฅผ ์ตœ์ ํ™”ํ•˜๊ณ  ๊ฐœ์„ ์ ์„ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”:\nSELECT * FROM orders o\nLEFT JOIN customers c ON o.customer_id = c.id\nWHERE YEAR(o.order_date) = 2023\nAND c.country = 'Korea'\nORDER BY o.order_date DESC;"],
603
+ ["๋‹ค์Œ ๋งˆ์ผ€ํŒ… ์บ ํŽ˜์ธ์˜ ROI๋ฅผ ๋ถ„์„ํ•˜๊ณ  ๊ฐœ์„ ๋ฐฉ์•ˆ์„ ์ œ์‹œํ•ด์ฃผ์„ธ์š”:\n์ด ๋น„์šฉ: 5000๋งŒ์›\n๋„๋‹ฌ์ž ์ˆ˜: 100๋งŒ๋ช…\nํด๋ฆญ๋ฅ : 2.3%\n์ „ํ™˜์œจ: 0.8%\nํ‰๊ท  ๊ตฌ๋งค์•ก: 35,000์›"],
604
+ ],
605
+ inputs=msg
606
+ )
607
+
608
+ # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
609
+ msg.submit(
610
+ stream_chat,
611
+ inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
612
+ outputs=[msg, chatbot]
613
+ )
614
 
615
+ send.click(
616
+ stream_chat,
617
+ inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
618
+ outputs=[msg, chatbot]
619
+ )
620
 
621
  file_upload.change(
622
  fn=init_msg,
 
629
  queue=True
630
  )
631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
  return demo
633
 
634
  if __name__ == "__main__":