Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
def ask(txt):
|
5 |
+
print("Asked!")
|
6 |
+
return "Fun", "Times"
|
7 |
+
|
8 |
+
|
9 |
+
desc = "Description"
|
10 |
+
article_text = "Article Text!"
|
11 |
+
|
12 |
+
callback = gr.CSVLogger()
|
13 |
+
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
gr.Markdown(
|
17 |
+
"""
|
18 |
+
# Maryland Kids Law!
|
19 |
+
Start typing below to see the output.
|
20 |
+
""")
|
21 |
+
txt = gr.Textbox(label="Ask your question:", lines=5,
|
22 |
+
placeholder="Is it ok to punch a kid?")
|
23 |
+
txt_2 = gr.Textbox(placeholder="Your Question will appear here.",
|
24 |
+
label="Output", lines=5)
|
25 |
+
txt_3 = gr.Textbox(
|
26 |
+
placeholder="The references cited to answer your question will appear here.", label="References", lines=5)
|
27 |
+
btn = gr.Button(value="Ask!")
|
28 |
+
btn.click(ask, inputs=[txt], outputs=[txt_2, txt_3])
|
29 |
+
|
30 |
+
gr.examples = [
|
31 |
+
["What a beautiful morning for a walk!"],
|
32 |
+
["It was the best of times, it was the worst of times."]
|
33 |
+
]
|
34 |
+
gr.HTML("hello world!")
|
35 |
+
|
36 |
+
callback.setup([txt, txt_2, txt_3], "flagged_data_points")
|
37 |
+
# We can choose which components to flag -- in this case, we'll flag all of them
|
38 |
+
btn.click(lambda *args: callback.flag(args),
|
39 |
+
[txt, txt_2, txt_3], None, preprocess=False)
|
40 |
+
|
41 |
+
demo.launch()
|