Devavrat28 commited on
Commit
b7e8018
Β·
verified Β·
1 Parent(s): 481c9f8

Create app

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Gradio app
2
+ # app.py
3
+ # app.py - Original approach with profile object
4
+ import gradio as gr
5
+ import requests
6
+
7
+ MODAL_URL = "https://devsam2898--personal-investment-strategist-9-web.modal.run/strategy"
8
+
9
+ def get_investment_strategy(age_group, income, expenses, risk_profile, goal, timeframe):
10
+ """Get investment strategy from Modal backend"""
11
+ payload = {
12
+ "profile": {
13
+ "age_group": age_group,
14
+ "income": income,
15
+ "expenses": expenses,
16
+ "risk_profile": risk_profile,
17
+ "goal": goal,
18
+ "timeframe": timeframe
19
+ }
20
+ }
21
+ try:
22
+ response = requests.post(MODAL_URL, json=payload, timeout=60)
23
+ if response.status_code == 200:
24
+ return response.json().get("strategy", "No strategy returned.")
25
+ else:
26
+ return f"❌ Error {response.status_code}: {response.text}"
27
+ except Exception as e:
28
+ return f"❌ Network error: {str(e)}"
29
+
30
+ demo = gr.Interface(
31
+ fn=get_investment_strategy,
32
+ inputs=[
33
+ gr.Dropdown(["20s", "30s", "40s", "50s+"], label="Age Group", value="30s"),
34
+ gr.Textbox(label="Monthly Income ($)", value="6000"),
35
+ gr.Textbox(label="Monthly Expenses ($)", value="4000"),
36
+ gr.Radio(["Conservative", "Moderate", "Aggressive"], label="Risk Tolerance", value="Moderate"),
37
+ gr.Textbox(label="Financial Goal (e.g., buy a house)", value="retirement planning"),
38
+ gr.Textbox(label="Timeframe (e.g., 5 years)", value="10 years")
39
+ ],
40
+ outputs=gr.Markdown(label="Investment Strategy"),
41
+ title="πŸ“ˆ Personal Finance Strategist",
42
+ description="Powered by LlamaIndex + Nebius Qwen3 | Get personalized strategies based on life stage and goals.",
43
+ theme="soft",
44
+ allow_flagging="never"
45
+ )
46
+
47
+ if __name__ == "__main__":
48
+ demo.launch()