Spaces:
Sleeping
Sleeping
fixing logic errors + formatting
Browse files
app.py
CHANGED
|
@@ -86,7 +86,7 @@ def respond(message, history):
|
|
| 86 |
yield response
|
| 87 |
|
| 88 |
usedSections = list(dict.fromkeys(topSections))
|
| 89 |
-
citation = "\n\n* Sources: " + ", ".join(usedSections) + "*"
|
| 90 |
yield response + citation
|
| 91 |
|
| 92 |
custom_css = """
|
|
@@ -135,17 +135,25 @@ def goalTracker(goal, savings, targetDate):
|
|
| 135 |
remaining = goal - savings
|
| 136 |
if remaining <= 0:
|
| 137 |
return "Congratulations on hitting your goal!"
|
| 138 |
-
|
| 139 |
weeklyAmount = remaining / (daysLeft / 7)
|
| 140 |
monthlyAmount = remaining / (daysLeft / 30.44)
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
with gr.Blocks(css=custom_css) as demo:
|
| 151 |
gr.Image("banner_image.png", show_label=False, container=False)
|
|
@@ -177,7 +185,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 177 |
)
|
| 178 |
|
| 179 |
with gr.Tab("Budget Calculator"):
|
| 180 |
-
gr.Markdown("#
|
| 181 |
gr.Markdown("Want to see what your monthly budget might look like when following financial literacy principles? Enter your monthly income to see the suggested breakdown!")
|
| 182 |
incomeInput = gr.Number(label = "Monthly Income ($)", minimum = 0)
|
| 183 |
budgetOutput = gr.Markdown(label = "Monthly Budget")
|
|
@@ -185,7 +193,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 185 |
budgetButton.click(fn = budgetCalculator, inputs = incomeInput, outputs = budgetOutput)
|
| 186 |
|
| 187 |
with gr.Tab("Goal Tracker"):
|
| 188 |
-
gr.Markdown("#
|
| 189 |
gr.Markdown("Saving up to buy something special? Want to figure out how long it'll take to reach that goal? Enter your goal amount, current savings, and target date to see the suggested timeline!")
|
| 190 |
goalInput = gr.Number(label = "Savings Goal ($)", minimum = 0)
|
| 191 |
savingsInput = gr.Number(label = "Current Savings ($)", minimum = 0)
|
|
|
|
| 86 |
yield response
|
| 87 |
|
| 88 |
usedSections = list(dict.fromkeys(topSections))
|
| 89 |
+
citation = "\n\n* 📋 Sources: " + ", ".join(usedSections) + "*"
|
| 90 |
yield response + citation
|
| 91 |
|
| 92 |
custom_css = """
|
|
|
|
| 135 |
remaining = goal - savings
|
| 136 |
if remaining <= 0:
|
| 137 |
return "Congratulations on hitting your goal!"
|
| 138 |
+
|
| 139 |
weeklyAmount = remaining / (daysLeft / 7)
|
| 140 |
monthlyAmount = remaining / (daysLeft / 30.44)
|
| 141 |
|
| 142 |
+
if daysLeft >= 28:
|
| 143 |
+
return (
|
| 144 |
+
f"### Goal Tracker Results\n\n"
|
| 145 |
+
f"- **Amount Remaining:** ${remaining:,.2f}\n"
|
| 146 |
+
f"- **Days Remaining:** {daysLeft}\n"
|
| 147 |
+
f"- **Save this much per week:** ${weeklyAmount:,.2f}\n"
|
| 148 |
+
f"- **Save this much per month:** ${monthlyAmount:,.2f}\n"
|
| 149 |
+
)
|
| 150 |
+
elif daysLeft >= 7:
|
| 151 |
+
return (
|
| 152 |
+
f"### Goal Tracker Results\n\n"
|
| 153 |
+
f"- **Amount Remaining:** ${remaining:,.2f}\n"
|
| 154 |
+
f"- **Days Remaining:** {daysLeft}\n"
|
| 155 |
+
f"- **Save this much per week:** ${weeklyAmount:,.2f}\n"
|
| 156 |
+
)
|
| 157 |
|
| 158 |
with gr.Blocks(css=custom_css) as demo:
|
| 159 |
gr.Image("banner_image.png", show_label=False, container=False)
|
|
|
|
| 185 |
)
|
| 186 |
|
| 187 |
with gr.Tab("Budget Calculator"):
|
| 188 |
+
gr.Markdown("# 50/30/20 Budget Calculator 📑")
|
| 189 |
gr.Markdown("Want to see what your monthly budget might look like when following financial literacy principles? Enter your monthly income to see the suggested breakdown!")
|
| 190 |
incomeInput = gr.Number(label = "Monthly Income ($)", minimum = 0)
|
| 191 |
budgetOutput = gr.Markdown(label = "Monthly Budget")
|
|
|
|
| 193 |
budgetButton.click(fn = budgetCalculator, inputs = incomeInput, outputs = budgetOutput)
|
| 194 |
|
| 195 |
with gr.Tab("Goal Tracker"):
|
| 196 |
+
gr.Markdown("# Savings Goal Tracker 🪙")
|
| 197 |
gr.Markdown("Saving up to buy something special? Want to figure out how long it'll take to reach that goal? Enter your goal amount, current savings, and target date to see the suggested timeline!")
|
| 198 |
goalInput = gr.Number(label = "Savings Goal ($)", minimum = 0)
|
| 199 |
savingsInput = gr.Number(label = "Current Savings ($)", minimum = 0)
|