wop commited on
Commit
2f2bff4
·
1 Parent(s): 84fef76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -16,32 +16,32 @@ def query2(payload):
16
  return response.json()
17
 
18
  def detect_context_from_question(inputs, outputs):
19
- question = inputs["a"]
20
  output = query({
21
  "inputs": f"context for '{question}' is:",
22
  })
23
- inputs["b"].value = output # Update the value of the context Textbox
24
 
25
  def ask_question(inputs, outputs):
26
- question = inputs["a"]
27
- context = inputs["b"]
28
  output2 = query2({
29
  "inputs": {
30
  "question": question,
31
  "context": context
32
  },
33
  })
34
- outputs["answer"].value = output2 # Update the value of the answer Textbox
35
 
36
  iface = gr.Interface(
37
  fn=ask_question,
38
  inputs=[
39
- gr.Textbox("Enter your question", type="text", placeholder="Enter your question", name="a"),
40
- gr.Textbox("Enter context", type="text", placeholder="Enter context", name="b"),
41
- gr.Button(detect_context_from_question, text="Detect Context", name="detect_button"),
42
- gr.Button("Ask", name="ask_button")
43
  ],
44
- outputs=gr.Textbox("Answer", type="text", placeholder="Answer", name="answer"), # Single Textbox for the answer
45
  live=True
46
  )
47
 
 
16
  return response.json()
17
 
18
  def detect_context_from_question(inputs, outputs):
19
+ question = inputs[0]
20
  output = query({
21
  "inputs": f"context for '{question}' is:",
22
  })
23
+ inputs[1] = output # Update the value of the context Textbox
24
 
25
  def ask_question(inputs, outputs):
26
+ question = inputs[0]
27
+ context = inputs[1]
28
  output2 = query2({
29
  "inputs": {
30
  "question": question,
31
  "context": context
32
  },
33
  })
34
+ outputs[0] = output2 # Update the value of the answer Textbox
35
 
36
  iface = gr.Interface(
37
  fn=ask_question,
38
  inputs=[
39
+ gr.Textbox(type="text", placeholder="Enter your question"),
40
+ gr.Textbox(type="text", placeholder="Enter context"),
41
+ gr.Button(detect_context_from_question, text="Detect Context"),
42
+ gr.Button("Ask")
43
  ],
44
+ outputs=gr.Textbox(type="text", placeholder="Answer"), # Single Textbox for the answer
45
  live=True
46
  )
47