wop commited on
Commit
1619dde
·
1 Parent(s): 7458ca4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -15,17 +15,25 @@ def query2(payload):
15
  response = requests.post(API_URL2, headers=headers2, json=payload)
16
  return response.json()
17
 
18
- def inference_ui(question, context_input):
19
  output = query({
20
- "inputs": f"context for '{question}' is: {context_input}",
21
  })
 
 
 
 
 
22
  output2 = query2({
23
  "inputs": {
24
  "question": question,
25
- "context": output['context'] # Ensure that 'context' is a string
26
  },
27
  })
28
  return output2
29
 
30
- iface = gr.Interface(fn=inference_ui, inputs=["text", "text"], outputs="text")
31
- iface.launch()
 
 
 
 
15
  response = requests.post(API_URL2, headers=headers2, json=payload)
16
  return response.json()
17
 
18
+ def inference_ui(question):
19
  output = query({
20
+ "inputs": f"context for '{question}' is:",
21
  })
22
+ return output['context']
23
+
24
+ def ask_question_ui():
25
+ question = gr.textbox("Enter your question:")
26
+ context = gr.textbox("Enter context:")
27
  output2 = query2({
28
  "inputs": {
29
  "question": question,
30
+ "context": context
31
  },
32
  })
33
  return output2
34
 
35
+ iface_context = gr.Interface(fn=inference_ui, inputs="text", outputs="text", live=True)
36
+ iface_ask_question = gr.Interface(fn=ask_question_ui, inputs=["text", "text"], outputs="text", live=True)
37
+
38
+ iface_context.launch(share=True)
39
+ iface_ask_question.launch(share=True)