wop commited on
Commit
4ce7f25
1 Parent(s): d1d7e61

Update app.py

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