store_example / app.py
cdactvm's picture
Create app.py
4b4bebd verified
raw
history blame
1.2 kB
import gradio as gr
def ask(txt):
print("Asked!")
return "Fun", "Times"
desc = "Description"
article_text = "Article Text!"
callback = gr.CSVLogger()
with gr.Blocks() as demo:
gr.Markdown(
"""
# Maryland Kids Law!
Start typing below to see the output.
""")
txt = gr.Textbox(label="Ask your question:", lines=5,
placeholder="Is it ok to punch a kid?")
txt_2 = gr.Textbox(placeholder="Your Question will appear here.",
label="Output", lines=5)
txt_3 = gr.Textbox(
placeholder="The references cited to answer your question will appear here.", label="References", lines=5)
btn = gr.Button(value="Ask!")
btn.click(ask, inputs=[txt], outputs=[txt_2, txt_3])
gr.examples = [
["What a beautiful morning for a walk!"],
["It was the best of times, it was the worst of times."]
]
gr.HTML("hello world!")
callback.setup([txt, txt_2, txt_3], "flagged_data_points")
# We can choose which components to flag -- in this case, we'll flag all of them
btn.click(lambda *args: callback.flag(args),
[txt, txt_2, txt_3], None, preprocess=False)
demo.launch()