import gradio as gr from modules.utils import load_css from modules.retirement_planning import retirement_planning def retirement_planning_interface_fn( current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield ): result = retirement_planning( current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield ) css = load_css() return css + result # Define the input components current_age = gr.Slider(label="Current Age (15-60 Years)", value=15, minimum=15, maximum=60, step=1) retirement_age = gr.Slider(label="Retirement Age (Upto 70 Years)", value=55, minimum=15, maximum=70, step=1) life_expectancy = gr.Slider(label="Life Expectancy (Upto 100 Years)", value=80, minimum=30, maximum=100, step=1) monthly_income_required = gr.Number(label="Monthly Income Required In Retirement Years (CPP)", value=2000000) inflation_rate = gr.Number(label="Expected Inflation Rate (%)", value=3) current_investment = gr.Number(label="Current Investment", value=10000000) monthly_investment = gr.Number(label="Monthly Investment", value=500000) annual_increase_in_monthly_investment = gr.Number(label="Annual Increase in Monthly Investment", value=0) # 추가된 입력 reinvest_dividends = gr.Checkbox(label="Reinvest Dividends", value=True) pre_retirement_roi = gr.Number(label="Expected Return On Investment (Pre-retirement) (%)", value=8) pre_retirement_dividend_yield = gr.Number(label="Expected Dividend Yield (Pre-retirement) (%)", value=3.3) post_retirement_roi = gr.Number(label="Expected Return On Investment (Post-retirement) (%)", value=8) post_retirement_dividend_yield = gr.Number(label="Expected Dividend Yield (Post-retirement) (%)", value=3.3) retirement_planning_inputs = [current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield] output = gr.HTML() # Define the update function def update_output( current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield ): return retirement_planning_interface_fn( current_age, retirement_age, life_expectancy, monthly_income_required, inflation_rate, current_investment, monthly_investment, annual_increase_in_monthly_investment, reinvest_dividends, pre_retirement_roi, pre_retirement_dividend_yield, post_retirement_roi, post_retirement_dividend_yield )