Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,32 @@ def carbonFootPrintAI(monthly_oil_bill: int,
|
|
| 10 |
number_of_flights_in_past_year_more_or_equal_4hours: int,
|
| 11 |
recycle_newspaper=False,
|
| 12 |
recycle_aluminium_and_tin=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
api_key = os.getenv("GEMINI_API_KEY")
|
| 15 |
|
|
@@ -69,7 +95,6 @@ def carbonFootPrintAI(monthly_oil_bill: int,
|
|
| 69 |
response4 = model.generate_content(prompt4)
|
| 70 |
return [total_footprint, response4.text]
|
| 71 |
|
| 72 |
-
|
| 73 |
css = """
|
| 74 |
.app {
|
| 75 |
border-width: 3px;
|
|
@@ -98,4 +123,4 @@ app = gr.Interface(
|
|
| 98 |
title = "🌿 🌍 Carbon Footprint Calculator 🌍 🌿"
|
| 99 |
)
|
| 100 |
|
| 101 |
-
app.launch()
|
|
|
|
| 10 |
number_of_flights_in_past_year_more_or_equal_4hours: int,
|
| 11 |
recycle_newspaper=False,
|
| 12 |
recycle_aluminium_and_tin=False):
|
| 13 |
+
|
| 14 |
+
"""
|
| 15 |
+
This function calculates the carbon footprint based on the following parameters:
|
| 16 |
+
- Monthly oil bill in dollars
|
| 17 |
+
- Monthly gas bill in dollars
|
| 18 |
+
- Monthly electricity bill in dollars
|
| 19 |
+
- Total yearly mileage on car in miles
|
| 20 |
+
- Number of flights in the past year that are less than or equal to 4 hours
|
| 21 |
+
- Number of flights in the past year that are more than or equal to 4 hours
|
| 22 |
+
- recycle_newspaper: Indicating whether or not the user recycles newspaper
|
| 23 |
+
- recycle_aluminium_and_tin: Indicating whether or not the user recycles aluminium and tin.
|
| 24 |
+
|
| 25 |
+
Args:
|
| 26 |
+
monthly_oil_bill (int): Monthly oil bill in dollars
|
| 27 |
+
monthly_gas_bill (int): Monthly gas bill in dollars
|
| 28 |
+
monthly_electricity_bill (int): Monthly electricity bill in dollars
|
| 29 |
+
total_yearly_mileage_on_car (int): Total yearly mileage on car in miles
|
| 30 |
+
number_of_flights_in_past_year_less_or_equal_4hours (int): Number of flights in the past year that are less than or equal to 4 hours
|
| 31 |
+
number_of_flights_in_past_year_more_or_equal_4hours (int): Number of flights in the past year that are more than or equal to 4 hours
|
| 32 |
+
recycle_newspaper (bool): Boolean indicating if the user recycles newspaper
|
| 33 |
+
recycle_aluminium_and_tin (bool): Boolean indicating if the user recycles aluminium and tin.
|
| 34 |
+
|
| 35 |
+
Returns:
|
| 36 |
+
- total_footprint (int): The total carbon footprint calculated based on the inputs
|
| 37 |
+
- response (str): A recommendation message based on the total carbon footprint.
|
| 38 |
+
"""
|
| 39 |
|
| 40 |
api_key = os.getenv("GEMINI_API_KEY")
|
| 41 |
|
|
|
|
| 95 |
response4 = model.generate_content(prompt4)
|
| 96 |
return [total_footprint, response4.text]
|
| 97 |
|
|
|
|
| 98 |
css = """
|
| 99 |
.app {
|
| 100 |
border-width: 3px;
|
|
|
|
| 123 |
title = "🌿 🌍 Carbon Footprint Calculator 🌍 🌿"
|
| 124 |
)
|
| 125 |
|
| 126 |
+
app.launch(mcp_server = True)
|