Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,23 +15,23 @@ def query2(payload):
|
|
| 15 |
response = requests.post(API_URL2, headers=headers2, json=payload)
|
| 16 |
return response.json()
|
| 17 |
|
| 18 |
-
def detect_context_from_question(
|
| 19 |
-
question = inputs[0]
|
| 20 |
output = query({
|
| 21 |
"inputs": f"context for '{question}' is:",
|
| 22 |
})
|
| 23 |
-
inputs[1] = output # Update the value of the context Textbox
|
| 24 |
|
| 25 |
-
def ask_question(
|
| 26 |
-
question = inputs[0]
|
| 27 |
-
context = inputs[1]
|
| 28 |
output2 = query2({
|
| 29 |
"inputs": {
|
| 30 |
"question": question,
|
| 31 |
"context": context
|
| 32 |
},
|
| 33 |
})
|
| 34 |
-
outputs[0] = output2 # Update the value of the answer Textbox
|
| 35 |
|
| 36 |
iface = gr.Interface(
|
| 37 |
fn=ask_question,
|
|
@@ -46,3 +46,4 @@ iface = gr.Interface(
|
|
| 46 |
)
|
| 47 |
|
| 48 |
iface.launch()
|
|
|
|
|
|
| 15 |
response = requests.post(API_URL2, headers=headers2, json=payload)
|
| 16 |
return response.json()
|
| 17 |
|
| 18 |
+
def detect_context_from_question():
|
| 19 |
+
question = detect_context_from_question.inputs[0].value
|
| 20 |
output = query({
|
| 21 |
"inputs": f"context for '{question}' is:",
|
| 22 |
})
|
| 23 |
+
detect_context_from_question.inputs[1].value = output # Update the value of the context Textbox
|
| 24 |
|
| 25 |
+
def ask_question():
|
| 26 |
+
question = ask_question.inputs[0].value
|
| 27 |
+
context = ask_question.inputs[1].value
|
| 28 |
output2 = query2({
|
| 29 |
"inputs": {
|
| 30 |
"question": question,
|
| 31 |
"context": context
|
| 32 |
},
|
| 33 |
})
|
| 34 |
+
ask_question.outputs[0].value = output2 # Update the value of the answer Textbox
|
| 35 |
|
| 36 |
iface = gr.Interface(
|
| 37 |
fn=ask_question,
|
|
|
|
| 46 |
)
|
| 47 |
|
| 48 |
iface.launch()
|
| 49 |
+
|