Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,32 +16,32 @@ def query2(payload):
|
|
| 16 |
return response.json()
|
| 17 |
|
| 18 |
def detect_context_from_question(inputs, outputs):
|
| 19 |
-
question = inputs[
|
| 20 |
output = query({
|
| 21 |
"inputs": f"context for '{question}' is:",
|
| 22 |
})
|
| 23 |
-
inputs[
|
| 24 |
|
| 25 |
def ask_question(inputs, outputs):
|
| 26 |
-
question = inputs[
|
| 27 |
-
context = inputs[
|
| 28 |
output2 = query2({
|
| 29 |
"inputs": {
|
| 30 |
"question": question,
|
| 31 |
"context": context
|
| 32 |
},
|
| 33 |
})
|
| 34 |
-
outputs[
|
| 35 |
|
| 36 |
iface = gr.Interface(
|
| 37 |
fn=ask_question,
|
| 38 |
inputs=[
|
| 39 |
-
gr.Textbox(
|
| 40 |
-
gr.Textbox(
|
| 41 |
-
gr.Button(detect_context_from_question, text="Detect Context"
|
| 42 |
-
gr.Button("Ask"
|
| 43 |
],
|
| 44 |
-
outputs=gr.Textbox(
|
| 45 |
live=True
|
| 46 |
)
|
| 47 |
|
|
|
|
| 16 |
return response.json()
|
| 17 |
|
| 18 |
def detect_context_from_question(inputs, outputs):
|
| 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(inputs, outputs):
|
| 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,
|
| 38 |
inputs=[
|
| 39 |
+
gr.Textbox(type="text", placeholder="Enter your question"),
|
| 40 |
+
gr.Textbox(type="text", placeholder="Enter context"),
|
| 41 |
+
gr.Button(detect_context_from_question, text="Detect Context"),
|
| 42 |
+
gr.Button("Ask")
|
| 43 |
],
|
| 44 |
+
outputs=gr.Textbox(type="text", placeholder="Answer"), # Single Textbox for the answer
|
| 45 |
live=True
|
| 46 |
)
|
| 47 |
|