dummy_99 / app.py
ysharma's picture
ysharma HF Staff
inrteractive dd
047cb68
import random
import gradio as gr
def random_list():
"""
Generate a random list of integers.
"""
length = 5
start = random.randint(1, 5)
end = random.randint(10, 35)
tmp_list = [random.randint(start, end) for _ in range(length)]
print(f"list is ^^-{tmp_list}")
return gr.update(choices = tmp_list)
def sentence_builder(quantity, animal, countries, place, activity_list, morning):
return f"""The {quantity} {animal}s from {" and ".join(countries)} went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
with gr.Blocks(theme=gr.themes.Soft()) as block_demo:
with gr.Row(elem_id="first"):
with gr.Column():
gr.Markdown("""# Ask Brain!""", elem_id="title")
with gr.Row(elem_id="secondrow"):
with gr.Column(scale=1, elem_id="inputsCol"):
brain_name = gr.Dropdown(label="Brain Name", choices=None, elem_id="name", multiselect=False, interactive=True)
question = gr.Textbox(
label="Question", lines=2, elem_id="question")
with gr.Accordion(label="Advance Options", open=False, elem_id="advanced") as a:
temperature = gr.Slider(
minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature", elem_id="temp")
maxTokens = gr.Slider(minimum=500, maximum=2000,
step=100, value=1000, label="Max Tokens", elem_id="tokens")
submit_button = gr.Button(label="Submit", elem_id="button")
with gr.Column(scale=1, elem_id="outputCol",):
output_text = gr.TextArea(
label="Brain Output", lines=14, elem_id="output").style(show_copy_button=True)
#submit_button.click(
# handleSubmit, [brain_name, question, temperature, maxTokens], output_text)
block_demo.load(random_list, [],brain_name )
block_demo.launch()