Spaces:
Running
on
Zero
Running
on
Zero
cutechicken
commited on
Commit
โข
c53bcba
1
Parent(s):
e468070
Update app.py
Browse files
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 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
|
544 |
-
with gr.
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
)
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์... ๐ญ",
|
559 |
-
container=False,
|
560 |
-
elem_classes="input-textbox",
|
561 |
-
scale=1
|
562 |
)
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
"์ ์ก",
|
567 |
-
elem_classes="send-button custom-button",
|
568 |
-
scale=1
|
569 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
570 |
|
571 |
-
|
572 |
-
|
573 |
-
|
|
|
|
|
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__":
|