File size: 5,537 Bytes
794a200
 
f2dd871
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ceb5307
f2dd871
 
 
 
 
 
 
 
 
 
794a200
ceb5307
f2dd871
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63ffaf9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import gradio as gr

def create_ui():
    def generate_plan(property_type, retrofit_area, building_age, blueprints, heating_system, cooling_system, insulation_quality, known_issues, energy_source, windows, monthly_bills, mortgage, mortgage_years, gross_income, monthly_expenses, credit_score, financing_term, preferred_term, budget, financing_interest):
        retrofit_plan = (
            f"Property Type: {property_type}\n"
            f"Retrofit Area: {retrofit_area} sqft\n"
            f"Building Age: {building_age} years\n"
            f"Blueprints or Energy Audits: {blueprints}\n"
            f"Heating System: {heating_system}\n"
            f"Cooling System: {cooling_system}\n"
            f"Insulation Quality: {insulation_quality}\n"
            f"Known Issues: {known_issues}\n"
            f"Energy Source: {energy_source}\n"
            f"Windows: {windows}\n"
            f"Monthly Heating and Electricity Bills: ${monthly_bills}\n"
            f"Mortgage: {mortgage}\n"
            f"Mortgage Years Remaining: {mortgage_years} years\n"
            f"Gross Income: ${gross_income}/month\n"
            f"Monthly Expenses: ${monthly_expenses}\n"
            f"Credit Score: {credit_score}\n"
            f"Financing Term: {financing_term}\n"
            f"Preferred Financing Term: {preferred_term}\n"
            f"Budget: {budget}\n"
            f"Interested in Financing: {financing_interest}\n"
        )
        return retrofit_plan

    def calculate_cost(retrofit_area, insulation_quality, known_issues, energy_source, windows):
        base_cost = 5000
        area_cost = retrofit_area * 10
        insulation_cost = {'Poor': 3000, 'Average': 2000, 'Good': 1000, 'Excellent': 500}[insulation_quality]
        issues_cost = 2000 if known_issues == 'Yes' else 0
        windows_cost = {'Yes': 3000, 'No': 5000, 'Unsure': 4000}[windows]
        energy_cost = {'Electricity': 1000, 'Natural gas': 2000, 'Oil': 3000, 'Renewable': 500}[energy_source]

        total_cost = base_cost + area_cost + insulation_cost + issues_cost + windows_cost + energy_cost
        return f"Estimated Retrofit Cost: ${total_cost}"

    with gr.Blocks() as demo:
        with gr.TabItem("Property Information"):
            property_type = gr.Dropdown(label="Type of Property", choices=["Single-family home", "Multi-family building", "Other residential"])
            retrofit_area = gr.Number(label="Retrofit Area (sqft)")
            building_age = gr.Number(label="Building Age (years)")
            blueprints = gr.Dropdown(label="Existing Blueprints or Energy Audits", choices=["Yes", "No"])
            heating_system = gr.Dropdown(label="Heating System", choices=["Furnace", "Boiler", "Heat pump", "None", "Other"])
            cooling_system = gr.Dropdown(label="Cooling System", choices=["Central air conditioning", "Window units", "None", "Other"])
            insulation_quality = gr.Dropdown(label="Insulation Quality", choices=["Poor", "Average", "Good", "Excellent"])
            known_issues = gr.Dropdown(label="Known Issues (e.g., leaks, drafts)", choices=["Yes", "No"])
            energy_source = gr.Dropdown(label="Primary Energy Source", choices=["Electricity", "Natural gas", "Oil", "Renewable", "Other"])
            windows = gr.Dropdown(label="Windows Double-Glazed", choices=["Yes", "No", "Unsure"])

        with gr.TabItem("Financial Information"):
            monthly_bills = gr.Number(label="Average Monthly Heating and Electricity Bills ($)")
            mortgage = gr.Dropdown(label="Do you have a mortgage?", choices=["Yes", "No"])
            mortgage_years = gr.Number(label="Years remaining on mortgage", visible=False)
            gross_income = gr.Number(label="Total Household Monthly Gross Income ($)")
            monthly_expenses = gr.Number(label="Total Monthly Household Expenses ($)")
            credit_score = gr.Number(label="Credit Score")
            financing_term = gr.Dropdown(label="Preferred Financing Term", choices=["Align with mortgage", "Different term"])
            preferred_term = gr.Dropdown(label="Preferred Term for Financing", choices=["5 years", "10 years", "15 years", "25 years"], visible=False)
            budget = gr.Dropdown(label="Budget for Retrofit Project", choices=["Under $10,000", "$10,000 to $50,000", "$50,000 to $100,000", "Over $100,000"])
            financing_interest = gr.Dropdown(label="Interested in Financing Options", choices=["Yes", "No"])

        with gr.TabItem("Generate Plan"):
            submit_btn = gr.Button("Generate Retrofit Plan")
            output_plan = gr.Textbox(label="Retrofit Plan")
            submit_btn.click(
                fn=generate_plan,
                inputs=[
                    property_type, retrofit_area, building_age, blueprints, heating_system, cooling_system, insulation_quality, known_issues, energy_source, windows,
                    monthly_bills, mortgage, mortgage_years, gross_income, monthly_expenses, credit_score, financing_term, preferred_term, budget, financing_interest
                ],
                outputs=output_plan
            )

        with gr.TabItem("Calculate Cost"):
            cost_btn = gr.Button("Calculate Retrofit Cost")
            output_cost = gr.Textbox(label="Estimated Cost")
            cost_btn.click(
                fn=calculate_cost,
                inputs=[retrofit_area, insulation_quality, known_issues, energy_source, windows],
                outputs=output_cost
            )

    demo.launch(server_name="0.0.0.0", server_port=7860, share=True)