paascorb commited on
Commit
1944061
1 Parent(s): 6e2bb61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -114,12 +114,13 @@ def predict(query,data):
114
  list_outputs = []
115
  for i in range(k):
116
  temp = [df.iloc[n] for n in range(k)][i]
117
- text = ''
118
- text += 'Probabilidades: '+ temp.Probabilidades + '\n\n'
119
- text += 'Respuesta: ' +temp.Respuesta + '\n\n'
120
- text += 'Contexto: '+temp.Contexto + '\n\n'
121
- list_outputs.append(text)
122
- return list_outputs
 
123
  except Exception as e:
124
  print(e)
125
  print(st)
@@ -192,13 +193,13 @@ def predict(query,data):
192
 
193
  list_outputs = []
194
  for i in range(k):
195
- text = ''
196
  temp = [df.iloc[n] for n in range(k)][i]
197
- text += 'Probabilidades: '+ temp.Probabilidades + '\n\n'
198
- text += 'Respuesta: ' +temp.Respuesta + '\n\n'
199
- text += 'Contexto: '+temp.Contexto + '\n\n'
200
-
201
- list_outputs.append(text)
 
202
 
203
  return list_outputs[0]
204
 
@@ -237,6 +238,7 @@ with gr.Blocks() as demo:
237
  ask = gr.Button("Preguntar")
238
  gr.Markdown("## Respuesta")
239
  answer = gr.Markdown(label="Respuesta")
 
240
  with gr.Accordion("Contexto", open=False):
241
  gr.Markdown(
242
  "### Contexto\n\nEl siguiente contexto ha sido utilizado para generar la respuesta:")
@@ -244,7 +246,9 @@ with gr.Blocks() as demo:
244
  # ask.click(fn=do_ask, inputs=[query, buildb,
245
  # dataset], outputs=[answer, context])
246
  ask.click(fn=predict, inputs=[query,
247
- file], outputs=[answer])
 
 
248
 
249
  demo.queue(concurrency_count=20)
250
  demo.launch(show_error=True)
 
114
  list_outputs = []
115
  for i in range(k):
116
  temp = [df.iloc[n] for n in range(k)][i]
117
+ tupla = (temp.Respuesta, temp.Contexto, temp.Probabilidades)
118
+ # text = ''
119
+ # text += 'Probabilidades: '+ temp.Probabilidades + '\n\n'
120
+ # text += 'Respuesta: ' +temp.Respuesta + '\n\n'
121
+ # text += 'Contexto: '+temp.Contexto + '\n\n'
122
+ list_outputs.append(tupla)
123
+ return list_outputs[0]
124
  except Exception as e:
125
  print(e)
126
  print(st)
 
193
 
194
  list_outputs = []
195
  for i in range(k):
 
196
  temp = [df.iloc[n] for n in range(k)][i]
197
+ tupla = (temp.Respuesta, temp.Contexto, temp.Probabilidades)
198
+ # text = ''
199
+ # text += 'Probabilidades: '+ temp.Probabilidades + '\n\n'
200
+ # text += 'Respuesta: ' +temp.Respuesta + '\n\n'
201
+ # text += 'Contexto: '+temp.Contexto + '\n\n'
202
+ list_outputs.append(tupla)
203
 
204
  return list_outputs[0]
205
 
 
238
  ask = gr.Button("Preguntar")
239
  gr.Markdown("## Respuesta")
240
  answer = gr.Markdown(label="Respuesta")
241
+ prob = gr.Markdown(label="Probabilidades")
242
  with gr.Accordion("Contexto", open=False):
243
  gr.Markdown(
244
  "### Contexto\n\nEl siguiente contexto ha sido utilizado para generar la respuesta:")
 
246
  # ask.click(fn=do_ask, inputs=[query, buildb,
247
  # dataset], outputs=[answer, context])
248
  ask.click(fn=predict, inputs=[query,
249
+ file], outputs=[answer, context, prob])
250
+
251
+ examples = ["¿Cuándo suelen comenzar las adicciones?","Entrevista Miguel Ruiz.txt"]
252
 
253
  demo.queue(concurrency_count=20)
254
  demo.launch(show_error=True)