wop commited on
Commit
fc3da96
·
1 Parent(s): 2613527

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -15,13 +15,13 @@ def query2(payload):
15
  response = requests.post(API_URL2, headers=headers2, json=payload)
16
  return response.json()
17
 
18
- def inference_ui(question, context):
19
  output = query({
20
- "inputs": f"context for '{question}' is: {context}",
21
  })
22
- return output['context']
23
 
24
- def ask_question_ui(question, context):
25
  output2 = query2({
26
  "inputs": {
27
  "question": question,
@@ -31,14 +31,14 @@ def ask_question_ui(question, context):
31
  return output2
32
 
33
  iface = gr.Interface(
34
- fn=ask_question_ui,
35
  inputs=[
36
- gr.Textbox("Enter your question", key="question"),
37
- gr.Textbox("Enter context", key="context"),
38
- gr.Button("Ask", key="ask_button"),
39
- gr.Button("AutoContext", key="autocontext_button")
40
  ],
41
- outputs=gr.Textbox("Output"),
42
  live=True
43
  )
44
 
 
15
  response = requests.post(API_URL2, headers=headers2, json=payload)
16
  return response.json()
17
 
18
+ def detect_context_from_question(question):
19
  output = query({
20
+ "inputs": f"context for '{question}' is:",
21
  })
22
+ return output
23
 
24
+ def ask_question(question, context):
25
  output2 = query2({
26
  "inputs": {
27
  "question": question,
 
31
  return output2
32
 
33
  iface = gr.Interface(
34
+ fn=ask_question,
35
  inputs=[
36
+ gr.Textbox("Enter your question", type="text", key="question"),
37
+ gr.Textbox("Enter context", type="text", key="context"),
38
+ "Detect Context", gr.Button(detect_context_from_question, key="detect_context_button"),
39
+ "Ask", gr.Button("Ask", key="ask_button")
40
  ],
41
+ outputs=gr.Textbox("Output", type="text"),
42
  live=True
43
  )
44