Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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,
|
| 19 |
payload = {"question": question}
|
| 20 |
result = query(payload)
|
| 21 |
-
|
| 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,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()
|