Spaces:
Paused
Paused
import gradio as gr | |
from gradio.themes.utils import colors | |
from t5 import T5 | |
from koalpaca import KoAlpaca | |
LOCAL_TEST = False | |
MODEL_STRS = ['T5', 'KoAlpaca'] | |
MODELS = [] | |
def prepare_theme(): | |
theme = gr.themes.Default(primary_hue=colors.gray, | |
secondary_hue=colors.emerald, | |
neutral_hue=colors.emerald).set( | |
body_background_fill="*primary_800", | |
body_background_fill_dark="*primary_800", | |
block_background_fill="*primary_700", | |
block_background_fill_dark="*primary_700", | |
border_color_primary="*secondary_300", | |
border_color_primary_dark="*secondary_300", | |
block_border_width="3px", | |
input_border_width="2px", | |
input_background_fill="*primary_700", | |
input_background_fill_dark="*primary_700", | |
background_fill_secondary="*primary_700", | |
background_fill_secondary_dark="*primary_700", | |
body_text_color="white", | |
body_text_color_dark="white", | |
block_label_text_color="*secondary_300", | |
block_label_text_color_dark="*secondary_300", | |
block_label_background_fill="*primary_800", | |
block_label_background_fill_dark="*primary_800", | |
color_accent_soft="*primary_600", | |
color_accent_soft_dark="*primary_600", | |
) | |
return theme | |
if __name__=='__main__': | |
theme = prepare_theme() | |
with open('README.txt', 'r') as f: | |
readme = f.read() | |
MODELS.append(T5()) | |
if not LOCAL_TEST: | |
MODELS.append(KoAlpaca()) | |
with gr.Blocks(theme=prepare_theme()) as demo: | |
with gr.Column(): | |
gr.HTML("<h1>KOMUChat</h1>") | |
with gr.Tab("μκ°"): | |
gr.Markdown(readme) | |
for i in range(len(MODELS)): | |
with gr.Tab(MODEL_STRS[i], id=i): | |
with gr.Column(): | |
chatbot = gr.Chatbot(label=MODEL_STRS[i], bubble_full_width=False) | |
txt = gr.Textbox(show_label=False, placeholder='μ°μ κ΄λ ¨ μ§λ¬Έμ μ λ ₯νμΈμ!', container=False, elem_id=i) | |
txt.submit(MODELS[i].chat, [txt, chatbot], [txt, chatbot]) | |
demo.launch(debug=True, share=True) |