Spaces:
Running
Running
acumplid
commited on
Commit
·
050bf4e
1
Parent(s):
36ea3d4
Add context
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ rag = RAG(
|
|
25 |
def generate(prompt, model_parameters):
|
26 |
try:
|
27 |
output, context = rag.get_response(prompt, model_parameters)
|
28 |
-
return output
|
29 |
except HTTPError as err:
|
30 |
if err.code == 400:
|
31 |
gr.Warning(
|
@@ -54,9 +54,8 @@ def submit_input(input_, num_chunks, max_new_tokens, repetition_penalty, top_k,
|
|
54 |
"TEMPERATURE": temperature
|
55 |
}
|
56 |
|
57 |
-
output = generate(input_, model_parameters)
|
58 |
-
|
59 |
-
return output
|
60 |
|
61 |
|
62 |
def change_interactive(text):
|
@@ -69,6 +68,8 @@ def clear():
|
|
69 |
return (
|
70 |
None,
|
71 |
None,
|
|
|
|
|
72 |
gr.Slider(value=100),
|
73 |
gr.Slider(value=1.2),
|
74 |
gr.Slider(value=50),
|
@@ -166,7 +167,15 @@ def gradio_app():
|
|
166 |
|
167 |
with gr.Column(variant="panel"):
|
168 |
output = Textbox(
|
169 |
-
lines=11,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
)
|
171 |
with gr.Row(variant="panel"):
|
172 |
clear_btn = Button(
|
@@ -175,6 +184,7 @@ def gradio_app():
|
|
175 |
submit_btn = Button("Submit", variant="primary", interactive=False)
|
176 |
|
177 |
|
|
|
178 |
|
179 |
|
180 |
input_.change(
|
@@ -197,7 +207,7 @@ def gradio_app():
|
|
197 |
clear_btn.click(
|
198 |
fn=clear,
|
199 |
inputs=[],
|
200 |
-
outputs=[input_, output] + parameters_compontents,
|
201 |
queue=False,
|
202 |
api_name=False
|
203 |
)
|
@@ -205,7 +215,7 @@ def gradio_app():
|
|
205 |
submit_btn.click(
|
206 |
fn=submit_input,
|
207 |
inputs=[input_]+ parameters_compontents,
|
208 |
-
outputs=[output],
|
209 |
api_name="get-results"
|
210 |
)
|
211 |
|
@@ -216,7 +226,7 @@ def gradio_app():
|
|
216 |
["""Què és l'EADOP (Entitat Autònoma del Diari Oficial i de Publicacions)?"""],
|
217 |
],
|
218 |
inputs=input_,
|
219 |
-
outputs=output,
|
220 |
fn=submit_input,
|
221 |
)
|
222 |
gr.Examples(
|
@@ -224,7 +234,7 @@ def gradio_app():
|
|
224 |
["""Què diu el decret sobre la senyalització de les begudes alcohòliques i el tabac a Catalunya?"""],
|
225 |
],
|
226 |
inputs=input_,
|
227 |
-
outputs=output,
|
228 |
fn=submit_input,
|
229 |
)
|
230 |
gr.Examples(
|
@@ -232,7 +242,7 @@ def gradio_app():
|
|
232 |
["""Com es pot inscriure una persona al Registre de catalans i catalanes residents a l'exterior?"""],
|
233 |
],
|
234 |
inputs=input_,
|
235 |
-
outputs=output,
|
236 |
fn=submit_input,
|
237 |
)
|
238 |
gr.Examples(
|
@@ -240,7 +250,7 @@ def gradio_app():
|
|
240 |
["""Quina és la finalitat del Servei Meterològic de Catalunya ?"""],
|
241 |
],
|
242 |
inputs=input_,
|
243 |
-
outputs=output,
|
244 |
fn=submit_input,
|
245 |
)
|
246 |
|
|
|
25 |
def generate(prompt, model_parameters):
|
26 |
try:
|
27 |
output, context = rag.get_response(prompt, model_parameters)
|
28 |
+
return output, context
|
29 |
except HTTPError as err:
|
30 |
if err.code == 400:
|
31 |
gr.Warning(
|
|
|
54 |
"TEMPERATURE": temperature
|
55 |
}
|
56 |
|
57 |
+
output, context = generate(input_, model_parameters)
|
58 |
+
return output, context
|
|
|
59 |
|
60 |
|
61 |
def change_interactive(text):
|
|
|
68 |
return (
|
69 |
None,
|
70 |
None,
|
71 |
+
None,
|
72 |
+
None,
|
73 |
gr.Slider(value=100),
|
74 |
gr.Slider(value=1.2),
|
75 |
gr.Slider(value=50),
|
|
|
167 |
|
168 |
with gr.Column(variant="panel"):
|
169 |
output = Textbox(
|
170 |
+
lines=11,
|
171 |
+
label="Output",
|
172 |
+
interactive=False,
|
173 |
+
show_copy_button=True
|
174 |
+
)
|
175 |
+
context_evaluation = Textbox(
|
176 |
+
label="Context evaluation",
|
177 |
+
interactive=False,
|
178 |
+
show_copy_button=True
|
179 |
)
|
180 |
with gr.Row(variant="panel"):
|
181 |
clear_btn = Button(
|
|
|
184 |
submit_btn = Button("Submit", variant="primary", interactive=False)
|
185 |
|
186 |
|
187 |
+
|
188 |
|
189 |
|
190 |
input_.change(
|
|
|
207 |
clear_btn.click(
|
208 |
fn=clear,
|
209 |
inputs=[],
|
210 |
+
outputs=[input_, output, context_evaluation] + parameters_compontents,
|
211 |
queue=False,
|
212 |
api_name=False
|
213 |
)
|
|
|
215 |
submit_btn.click(
|
216 |
fn=submit_input,
|
217 |
inputs=[input_]+ parameters_compontents,
|
218 |
+
outputs=[output,context_evaluation],
|
219 |
api_name="get-results"
|
220 |
)
|
221 |
|
|
|
226 |
["""Què és l'EADOP (Entitat Autònoma del Diari Oficial i de Publicacions)?"""],
|
227 |
],
|
228 |
inputs=input_,
|
229 |
+
outputs=[output,context_evaluation],
|
230 |
fn=submit_input,
|
231 |
)
|
232 |
gr.Examples(
|
|
|
234 |
["""Què diu el decret sobre la senyalització de les begudes alcohòliques i el tabac a Catalunya?"""],
|
235 |
],
|
236 |
inputs=input_,
|
237 |
+
outputs=[output,context_evaluation],
|
238 |
fn=submit_input,
|
239 |
)
|
240 |
gr.Examples(
|
|
|
242 |
["""Com es pot inscriure una persona al Registre de catalans i catalanes residents a l'exterior?"""],
|
243 |
],
|
244 |
inputs=input_,
|
245 |
+
outputs=[output,context_evaluation],
|
246 |
fn=submit_input,
|
247 |
)
|
248 |
gr.Examples(
|
|
|
250 |
["""Quina és la finalitat del Servei Meterològic de Catalunya ?"""],
|
251 |
],
|
252 |
inputs=input_,
|
253 |
+
outputs=[output,context_evaluation],
|
254 |
fn=submit_input,
|
255 |
)
|
256 |
|