Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests # Using requests instead of axios for Python
|
3 |
+
|
4 |
+
def make_decision(budget, interests):
|
5 |
+
interests = interests.split(',')
|
6 |
+
response = requests.post('http://localhost:3001/submitPreferences', {
|
7 |
+
"budget": budget,
|
8 |
+
"interests": interests
|
9 |
+
})
|
10 |
+
decision = response.json().get("decision") # Convert the response to JSON and get the 'decision' key
|
11 |
+
return decision
|
12 |
+
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=make_decision,
|
15 |
+
inputs=[
|
16 |
+
gr.inputs.Number(label="Budget"),
|
17 |
+
gr.inputs.Textbox(label="Interests (comma separated)")
|
18 |
+
],
|
19 |
+
outputs=gr.outputs.Textbox(label="Group Decision")
|
20 |
+
)
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
interface.launch()
|