Spaces:
Sleeping
Sleeping
elibrowne
commited on
Commit
·
d919aa0
1
Parent(s):
919be7b
Initial commit for Gradio app
Browse files
app.py
CHANGED
|
@@ -1,14 +1,63 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
return "Hello " + name + "!!"
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# VARIABLES: will eventually be loaded with JSON from a dataset
|
| 4 |
|
| 5 |
+
question_text = """
|
| 6 |
+
### Bar Question
|
| 7 |
+
What is the answer to this question?"""
|
| 8 |
+
answers_text = ["A", "B", "C", "D"]
|
| 9 |
|
| 10 |
+
# BLOCKS: main user interface
|
|
|
|
| 11 |
|
| 12 |
+
with gr.Blocks() as user_eval:
|
| 13 |
+
# Title text introducing study
|
| 14 |
+
gr.Markdown("""
|
| 15 |
+
# Legal Retriever Evaluation Study
|
| 16 |
+
Thank you for your participation! Here are some basic instructions on how to complete the legal study.
|
| 17 |
+
""")
|
| 18 |
|
| 19 |
+
# Passages and user evaluations thereof
|
| 20 |
+
with gr.Row(equal_height = False, visible = False) as evals:
|
| 21 |
+
with gr.Column(scale = 2) as passages:
|
| 22 |
+
passage_display = gr.Markdown("""
|
| 23 |
+
### Relevant Passages
|
| 24 |
+
- Dataset 1
|
| 25 |
+
- Dataset 2
|
| 26 |
+
- More text
|
| 27 |
+
- More text
|
| 28 |
+
- More text
|
| 29 |
+
- More text
|
| 30 |
+
### Auto-Generated Summary
|
| 31 |
+
This is a summary of the above legal passages, which imitates how a RAG system might \
|
| 32 |
+
encorporate retrieved data into its context to give a better response to a certain query.
|
| 33 |
+
""")
|
| 34 |
+
with gr.Column(scale = 1) as scores:
|
| 35 |
+
desc_1 = gr.Markdown("How **relevant** are these passages to our query?")
|
| 36 |
+
eval_1 = gr.Slider(1, 5)
|
| 37 |
+
desc_2 = gr.Markdown("How **novel** are these passages compared to the previous passages?")
|
| 38 |
+
eval_2 = gr.Slider(1, 5)
|
| 39 |
+
btn = gr.Button("Next")
|
| 40 |
+
# btn.click(fn=update, inputs=inp, outputs=eval_1)
|
| 41 |
+
|
| 42 |
+
# Question and answering dynamics
|
| 43 |
+
with gr.Row() as question:
|
| 44 |
+
with gr.Column():
|
| 45 |
+
gr.Markdown(question_text)
|
| 46 |
+
a = gr.Button(answers_text[0])
|
| 47 |
+
b = gr.Button(answers_text[1])
|
| 48 |
+
c = gr.Button(answers_text[2])
|
| 49 |
+
d = gr.Button(answers_text[3])
|
| 50 |
+
|
| 51 |
+
def answer():
|
| 52 |
+
return {
|
| 53 |
+
question: gr.Row(visible = False),
|
| 54 |
+
evals: gr.Row(visible = True)
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
a.click(fn = answer, outputs = [question, evals])
|
| 58 |
+
b.click(fn = answer, outputs = [question, evals])
|
| 59 |
+
c.click(fn = answer, outputs = [question, evals])
|
| 60 |
+
d.click(fn = answer, outputs = [question, evals])
|
| 61 |
+
|
| 62 |
+
# Starts on question, switches to evaluation after the user answers
|
| 63 |
+
user_eval.launch()
|