wop commited on
Commit
52bdf51
1 Parent(s): 1a8d189

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -15,19 +15,24 @@ def query2(payload):
15
  response = requests.post(API_URL2, headers=headers2, json=payload)
16
  return response.json()
17
 
18
- def get_context(question):
19
- payload = {"inputs": question}
20
  result = query(payload)
21
- return result['answer']
22
 
23
- def ask_ai(question, context):
24
  payload = {"question": question, "context": context}
25
  result = query2(payload)
26
- return result['answer']
27
 
28
  iface = gr.Interface(
29
  fn=ask_ai,
30
- inputs=[gr.Textbox("Question"), gr.Button("get_context", get_context)],
 
 
 
 
 
31
  outputs=gr.Textbox("Answer"),
32
  )
33
 
 
15
  response = requests.post(API_URL2, headers=headers2, json=payload)
16
  return response.json()
17
 
18
+ def get_context_func(question, context_output):
19
+ payload = {"question": question}
20
  result = query(payload)
21
+ context_output.update(result['answer'])
22
 
23
+ def ask_ai(question, context, answer_output):
24
  payload = {"question": question, "context": context}
25
  result = query2(payload)
26
+ answer_output.update(result['answer'])
27
 
28
  iface = gr.Interface(
29
  fn=ask_ai,
30
+ inputs=[
31
+ gr.Textbox("Question"),
32
+ gr.Textbox("Context"),
33
+ gr.Button("get_context", get_context_func),
34
+ gr.Button("ask_ai")
35
+ ],
36
  outputs=gr.Textbox("Answer"),
37
  )
38