Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
19 |
-
payload = {"
|
20 |
result = query(payload)
|
21 |
-
|
22 |
|
23 |
-
def ask_ai(question, context):
|
24 |
payload = {"question": question, "context": context}
|
25 |
result = query2(payload)
|
26 |
-
|
27 |
|
28 |
iface = gr.Interface(
|
29 |
fn=ask_ai,
|
30 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
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 |
|