File size: 1,808 Bytes
c360d3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
import random
def generate_sentence(num_animals, animal_type, countries, location, activities, time_of_day):
    country_str = ", ".join(countries)
    activity_str = ", ".join(activities)
    time = "์•„์นจ" if time_of_day else "์ €๋…"
    sentence = f"{country_str}์—์„œ ์˜จ {num_animals}๋งˆ๋ฆฌ์˜ {animal_type}์ด {location}์—์„œ {activity_str} ํ–ˆ์Šต๋‹ˆ๋‹ค. {time}๊นŒ์ง€."
    return sentence
with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            num_slider = gr.Slider(minimum=2, maximum=20, step=1, label="๋™๋ฌผ ์ˆ˜๋Ÿ‰", value=2)
            animal_dropdown = gr.Dropdown(
                choices=["๊ฐ•์•„์ง€", "๊ณ ์–‘์ด", "ํ† ๋ผ", "ํ–„์Šคํ„ฐ", "์•ต๋ฌด์ƒˆ"],
                label="๋™๋ฌผ ์ข…๋ฅ˜",
                value="๊ฐ•์•„์ง€"
            )
            countries = gr.CheckboxGroup(
                choices=["ํ•œ๊ตญ", "์ผ๋ณธ", "์ค‘๊ตญ", "๋ฏธ๊ตญ", "์˜๊ตญ"],
                label="๊ตญ๊ฐ€ ์„ ํƒ"
            )
            location = gr.Radio(
                choices=["๊ณต์›", "ํ•ด๋ณ€", "์‚ฐ", "๊ฐ•๊ฐ€", "์ˆฒ"],
                label="์žฅ์†Œ",
                value="๊ณต์›"
            )
            activities = gr.Dropdown(
                choices=["๋‹ฌ๋ฆฌ๊ธฐ", "์ˆ˜์˜", "์ž ์ž๊ธฐ", "๋†€๊ธฐ", "๋จน๊ธฐ"],
                label="ํ™œ๋™",
                multiselect=True
            )
            time_checkbox = gr.Checkbox(label="์•„์นจ(์ฒดํฌ) / ์ €๋…(๋ฏธ์ฒดํฌ)")
        with gr.Column():
            output_text = gr.Textbox(label="์ƒ์„ฑ๋œ ๋ฌธ์žฅ")
    generate_btn = gr.Button("๋ฌธ์žฅ ์ƒ์„ฑํ•˜๊ธฐ")
    generate_btn.click(
        fn=generate_sentence,
        inputs=[num_slider, animal_dropdown, countries, location, activities, time_checkbox],
        outputs=output_text
    )

if __name__ == '__main__':
    demo.launch()