Spaces:
Runtime error
Runtime error
Allen Park
commited on
Commit
·
f41fff5
1
Parent(s):
68c11f0
add upload & download file functions & gradio elements
Browse files
app.py
CHANGED
|
@@ -123,6 +123,13 @@ def model_call(question, document, answer, client_base_url):
|
|
| 123 |
combined_reasoning = " ".join(reasoning)[1:-1]
|
| 124 |
return combined_reasoning, score
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
# inputs = [
|
| 127 |
# gr.Textbox(label="Question"),
|
| 128 |
# gr.Textbox(label="Document"),
|
|
@@ -149,7 +156,12 @@ with gr.Blocks() as demo:
|
|
| 149 |
with gr.Column(scale=1):
|
| 150 |
reasoning = gr.Textbox(label="Reasoning")
|
| 151 |
score = gr.Textbox(label="Score (FAIL if Hallucinated, PASS if not)")
|
|
|
|
|
|
|
|
|
|
| 152 |
model_dropdown.change(fn=update_client_base_url, inputs=[model_dropdown], outputs=[base_url_state])
|
|
|
|
|
|
|
| 153 |
|
| 154 |
submit_button.click(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|
| 155 |
question.submit(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|
|
|
|
| 123 |
combined_reasoning = " ".join(reasoning)[1:-1]
|
| 124 |
return combined_reasoning, score
|
| 125 |
|
| 126 |
+
def upload_file(filepath):
|
| 127 |
+
name = Path(filepath).name
|
| 128 |
+
return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
|
| 129 |
+
|
| 130 |
+
def download_file():
|
| 131 |
+
return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
|
| 132 |
+
|
| 133 |
# inputs = [
|
| 134 |
# gr.Textbox(label="Question"),
|
| 135 |
# gr.Textbox(label="Document"),
|
|
|
|
| 156 |
with gr.Column(scale=1):
|
| 157 |
reasoning = gr.Textbox(label="Reasoning")
|
| 158 |
score = gr.Textbox(label="Score (FAIL if Hallucinated, PASS if not)")
|
| 159 |
+
u = gr.UploadButton("Upload a file", file_count="single")
|
| 160 |
+
d = gr.DownloadButton("Download the file", visible=False)
|
| 161 |
+
|
| 162 |
model_dropdown.change(fn=update_client_base_url, inputs=[model_dropdown], outputs=[base_url_state])
|
| 163 |
+
u.upload(upload_file, u, [u, d])
|
| 164 |
+
d.click(download_file, None, [u, d])
|
| 165 |
|
| 166 |
submit_button.click(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|
| 167 |
question.submit(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|