Spaces:
Sleeping
Sleeping
Allen Park
commited on
Commit
·
32e8378
1
Parent(s):
f1b5533
remove svg code and replace with label 'upload'; comment out downloadbutton gradio element and add clearbutton (to clear uploaded file)
Browse files
app.py
CHANGED
@@ -48,15 +48,6 @@ body, .gradio-container {
|
|
48 |
}
|
49 |
"""
|
50 |
|
51 |
-
formatted_upload_svg = '''
|
52 |
-
f<div style="display: flex; align-items: center; justify-content: center;">
|
53 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
54 |
-
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/>
|
55 |
-
<path d="M7.646 1.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 2.707V11.5a.5.5 0 0 1-1 0V2.707L5.354 4.854a.5.5 0 1 1-.708-.708z"/>
|
56 |
-
</svg>
|
57 |
-
</div>
|
58 |
-
'''
|
59 |
-
|
60 |
HEADER = """
|
61 |
# Patronus Lynx Demo
|
62 |
<table bgcolor="#1E2432" cellspacing="0" cellpadding="0" width="450">
|
@@ -142,10 +133,11 @@ def model_call(question, document, answer, client_base_url):
|
|
142 |
|
143 |
def upload_file(filepath):
|
144 |
name = Path(filepath).name
|
145 |
-
return
|
|
|
146 |
|
147 |
-
def download_file():
|
148 |
-
|
149 |
|
150 |
# inputs = [
|
151 |
# gr.Textbox(label="Question"),
|
@@ -166,14 +158,13 @@ with gr.Blocks(css=css) as demo:
|
|
166 |
with gr.Column(scale=1):
|
167 |
with gr.Row():
|
168 |
question = gr.Textbox(label="Question", scale=9)
|
169 |
-
u = gr.UploadButton(
|
170 |
-
|
|
|
171 |
with gr.Row():
|
172 |
-
|
173 |
-
document = gr.Textbox(label="Document")
|
174 |
with gr.Row():
|
175 |
-
|
176 |
-
answer = gr.Textbox(label="Answer")
|
177 |
with gr.Row():
|
178 |
clear_btn = gr.ClearButton([question, document, answer])
|
179 |
submit_button = gr.Button("Submit")
|
@@ -182,8 +173,8 @@ with gr.Blocks(css=css) as demo:
|
|
182 |
score = gr.Textbox(label="Score (FAIL if Hallucinated, PASS if not)")
|
183 |
|
184 |
model_dropdown.change(fn=update_client_base_url, inputs=[model_dropdown], outputs=[base_url_state])
|
185 |
-
u.upload(upload_file, u, [u,
|
186 |
-
d.click(download_file, None, [u, d])
|
187 |
|
188 |
submit_button.click(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|
189 |
question.submit(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|
|
|
48 |
}
|
49 |
"""
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
HEADER = """
|
52 |
# Patronus Lynx Demo
|
53 |
<table bgcolor="#1E2432" cellspacing="0" cellpadding="0" width="450">
|
|
|
133 |
|
134 |
def upload_file(filepath):
|
135 |
name = Path(filepath).name
|
136 |
+
return gr.UploadButton(visible=False)
|
137 |
+
# return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
|
138 |
|
139 |
+
# def download_file():
|
140 |
+
# return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
|
141 |
|
142 |
# inputs = [
|
143 |
# gr.Textbox(label="Question"),
|
|
|
158 |
with gr.Column(scale=1):
|
159 |
with gr.Row():
|
160 |
question = gr.Textbox(label="Question", scale=9)
|
161 |
+
u = gr.UploadButton("Upload", file_count="single", scale=1)
|
162 |
+
c = gr.ClearButton([u], visible=False, scale=1)
|
163 |
+
# d = gr.DownloadButton("Download the file", visible=False, scale=1)
|
164 |
with gr.Row():
|
165 |
+
document = gr.Textbox(label="Document")
|
|
|
166 |
with gr.Row():
|
167 |
+
answer = gr.Textbox(label="Answer")
|
|
|
168 |
with gr.Row():
|
169 |
clear_btn = gr.ClearButton([question, document, answer])
|
170 |
submit_button = gr.Button("Submit")
|
|
|
173 |
score = gr.Textbox(label="Score (FAIL if Hallucinated, PASS if not)")
|
174 |
|
175 |
model_dropdown.change(fn=update_client_base_url, inputs=[model_dropdown], outputs=[base_url_state])
|
176 |
+
u.upload(upload_file, u, [u, c])
|
177 |
+
# d.click(download_file, None, [u, d])
|
178 |
|
179 |
submit_button.click(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|
180 |
question.submit(fn=model_call, inputs=[question, document, answer, base_url_state], outputs=[reasoning, score])
|