eliasangels commited on
Commit
c22b4e8
·
verified ·
1 Parent(s): bc61a30

bug fix + compiling budget calculator

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -25,7 +25,7 @@ def preprocessText(text):
25
  chunk = chunk.strip()
26
  if not chunk:
27
  continue
28
- if chunk.startsith("===") and "SECTION:" in chunk:
29
  currentLabel = chunk.replace("===", "",).replace("SECTION:", "").strip()
30
  continue
31
  cleanedChunks.append(chunk)
@@ -129,4 +129,25 @@ with gr.Blocks(css=custom_css) as demo:
129
  """
130
  )
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  demo.launch()
 
25
  chunk = chunk.strip()
26
  if not chunk:
27
  continue
28
+ if chunk.startswith("===") and "SECTION:" in chunk:
29
  currentLabel = chunk.replace("===", "",).replace("SECTION:", "").strip()
30
  continue
31
  cleanedChunks.append(chunk)
 
129
  """
130
  )
131
 
132
+ def budgetCalculator(income):
133
+ if income is None or income <= 0:
134
+ return "Please enter a monthly income value that is greater than 0."
135
+ needs = income * 0.5
136
+ wants = income * 0.3
137
+ savings = income * 0.2
138
+ return (
139
+ f"### Your 50/30/20 Budget Breakdown:\n\n"
140
+ f"- **Needs (50%):** ${needs:,.2f}\n"
141
+ f"- **Wants (30%):** ${wants:,.2f}\n"
142
+ f"- **Savings (20%):** ${savings:,.2f}\n\n"
143
+ f"Based on a monthly income of ${income:,.2f}."
144
+ )
145
+
146
+ budgetTab = gr.Interface(
147
+ base = budgetCalculator,
148
+ inputs = gr.Number(label = "Monthly Income ($))", minimum = 0),
149
+ outputs = gr.Markdown(label = "Monthly Budget"),
150
+ title = "50/30/20 Budget Calculator",
151
+ description = "Want to see what your monthly budget might look like when following financial literacy principles? Enter your monthly income to see the suggested breakdown!"
152
+
153
  demo.launch()