Update app
Browse files
app.py
CHANGED
@@ -19,11 +19,18 @@ async def get_investment_strategy_async(age_group, income, expenses, risk_profil
|
|
19 |
return "β Please fill in all fields to get a personalized strategy."
|
20 |
|
21 |
# Convert income and expenses to numbers
|
|
|
|
|
22 |
try:
|
23 |
income_val = float(str(income).replace('$', '').replace(',', '')) if income else 0
|
24 |
expenses_val = float(str(expenses).replace('$', '').replace(',', '')) if expenses else 0
|
|
|
|
|
|
|
|
|
|
|
25 |
except ValueError:
|
26 |
-
return "β Please enter valid numbers for income and
|
27 |
|
28 |
# Validate financial logic
|
29 |
if income_val <= 0:
|
@@ -42,13 +49,13 @@ async def get_investment_strategy_async(age_group, income, expenses, risk_profil
|
|
42 |
"goal": goal,
|
43 |
"timeframe": timeframe,
|
44 |
"country": country,
|
45 |
-
"current_assets":
|
46 |
-
"current_liabilities":
|
47 |
}
|
48 |
}
|
49 |
|
50 |
try:
|
51 |
-
print(f"
|
52 |
|
53 |
# Use aiohttp for better async handling
|
54 |
timeout = aiohttp.ClientTimeout(total=150) # 2.5 minute timeout
|
|
|
19 |
return "β Please fill in all fields to get a personalized strategy."
|
20 |
|
21 |
# Convert income and expenses to numbers
|
22 |
+
# app.py - inside get_investment_strategy_async function
|
23 |
+
|
24 |
try:
|
25 |
income_val = float(str(income).replace('$', '').replace(',', '')) if income else 0
|
26 |
expenses_val = float(str(expenses).replace('$', '').replace(',', '')) if expenses else 0
|
27 |
+
|
28 |
+
# Handle current_assets and current_liabilities
|
29 |
+
assets_val = float(current_assets) if current_assets is not None and str(current_assets).strip() != "" else 0.0
|
30 |
+
liabilities_val = float(current_liabilities) if current_liabilities is not None and str(current_liabilities).strip() != "" else 0.0
|
31 |
+
|
32 |
except ValueError:
|
33 |
+
return "β Please enter valid numbers for income, expenses, assets, and liabilities."
|
34 |
|
35 |
# Validate financial logic
|
36 |
if income_val <= 0:
|
|
|
49 |
"goal": goal,
|
50 |
"timeframe": timeframe,
|
51 |
"country": country,
|
52 |
+
"current_assets": assets_val,
|
53 |
+
"current_liabilities": liabilities_val # Placeholder, can be extended later
|
54 |
}
|
55 |
}
|
56 |
|
57 |
try:
|
58 |
+
print(f"Sending request to: {MODAL_URL}")
|
59 |
|
60 |
# Use aiohttp for better async handling
|
61 |
timeout = aiohttp.ClientTimeout(total=150) # 2.5 minute timeout
|