Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,20 +19,29 @@ carbon_reduction_data = {
|
|
19 |
"Tires": 8.0,
|
20 |
}
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
# Sidebar with
|
36 |
st.sidebar.title("π RecycleSmart-PK")
|
37 |
st.sidebar.image(
|
38 |
"https://via.placeholder.com/300x200?text=RecycleSmart+Logo",
|
@@ -40,8 +49,7 @@ st.sidebar.image(
|
|
40 |
)
|
41 |
st.sidebar.markdown("### Navigation")
|
42 |
section = st.sidebar.radio(
|
43 |
-
"Choose a section:",
|
44 |
-
["Home", "Recycle Suggestions"]
|
45 |
)
|
46 |
|
47 |
# Main Content
|
@@ -54,17 +62,21 @@ if section == "Home":
|
|
54 |
st.markdown(
|
55 |
"""
|
56 |
RecycleSmart-PK helps you turn waste into opportunities while reducing your carbon footprint.
|
57 |
-
|
58 |
"""
|
59 |
)
|
60 |
|
61 |
elif section == "Recycle Suggestions":
|
62 |
st.title("π‘ Recycling Suggestions")
|
63 |
selected_items = st.multiselect(
|
64 |
-
"Select items to recycle:",
|
65 |
-
list(carbon_reduction_data.keys())
|
66 |
)
|
67 |
-
quantities = {
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
if st.button("Get Suggestions"):
|
70 |
if selected_items:
|
@@ -72,12 +84,23 @@ elif section == "Recycle Suggestions":
|
|
72 |
st.write("### β»οΈ Suggestions and Impact:")
|
73 |
for item, quantity in quantities.items():
|
74 |
if quantity > 0:
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
carbon_reduction = carbon_reduction_data.get(item, 0) * quantity
|
77 |
total_carbon_reduction += carbon_reduction
|
78 |
-
st.write(f"
|
79 |
st.write(f"π‘ {llm_response}")
|
80 |
-
st.write(
|
|
|
|
|
81 |
st.markdown("---")
|
82 |
st.write("### π Total Carbon Footprint Reduction π")
|
83 |
st.write(f"π **{total_carbon_reduction:.2f} kg COβ saved**")
|
|
|
19 |
"Tires": 8.0,
|
20 |
}
|
21 |
|
22 |
+
# Custom CSS for color and style
|
23 |
+
st.markdown(
|
24 |
+
"""
|
25 |
+
<style>
|
26 |
+
body {
|
27 |
+
background-color: #f0f2f6;
|
28 |
+
}
|
29 |
+
.main {
|
30 |
+
background-color: #ffffff;
|
31 |
+
border-radius: 10px;
|
32 |
+
padding: 20px;
|
33 |
+
color: #333333;
|
34 |
+
}
|
35 |
+
.sidebar .sidebar-content {
|
36 |
+
background-color: #eaf4fc;
|
37 |
+
border-radius: 10px;
|
38 |
+
}
|
39 |
+
</style>
|
40 |
+
""",
|
41 |
+
unsafe_allow_html=True,
|
42 |
+
)
|
43 |
|
44 |
+
# Sidebar with navigation
|
45 |
st.sidebar.title("π RecycleSmart-PK")
|
46 |
st.sidebar.image(
|
47 |
"https://via.placeholder.com/300x200?text=RecycleSmart+Logo",
|
|
|
49 |
)
|
50 |
st.sidebar.markdown("### Navigation")
|
51 |
section = st.sidebar.radio(
|
52 |
+
"Choose a section:", ["Home", "Recycle Suggestions"]
|
|
|
53 |
)
|
54 |
|
55 |
# Main Content
|
|
|
62 |
st.markdown(
|
63 |
"""
|
64 |
RecycleSmart-PK helps you turn waste into opportunities while reducing your carbon footprint.
|
65 |
+
Navigate to **Recycle Suggestions** to start recycling smartly!
|
66 |
"""
|
67 |
)
|
68 |
|
69 |
elif section == "Recycle Suggestions":
|
70 |
st.title("π‘ Recycling Suggestions")
|
71 |
selected_items = st.multiselect(
|
72 |
+
"Select items to recycle:", list(carbon_reduction_data.keys())
|
|
|
73 |
)
|
74 |
+
quantities = {
|
75 |
+
item: st.number_input(
|
76 |
+
f"Enter quantity for {item} (in kg):", min_value=0, step=1
|
77 |
+
)
|
78 |
+
for item in selected_items
|
79 |
+
}
|
80 |
|
81 |
if st.button("Get Suggestions"):
|
82 |
if selected_items:
|
|
|
84 |
st.write("### β»οΈ Suggestions and Impact:")
|
85 |
for item, quantity in quantities.items():
|
86 |
if quantity > 0:
|
87 |
+
prompt = (
|
88 |
+
f"Suggest profitable and eco-friendly uses for {quantity} kg of {item}, "
|
89 |
+
f"including household uses and ways to monetize them."
|
90 |
+
)
|
91 |
+
chat_completion = client.chat.completions.create(
|
92 |
+
messages=[{"role": "user", "content": prompt}],
|
93 |
+
model="llama-3.3-70b-versatile",
|
94 |
+
stream=False,
|
95 |
+
)
|
96 |
+
llm_response = chat_completion.choices[0].message.content
|
97 |
carbon_reduction = carbon_reduction_data.get(item, 0) * quantity
|
98 |
total_carbon_reduction += carbon_reduction
|
99 |
+
st.write(f"**{item} ({quantity} kg)**")
|
100 |
st.write(f"π‘ {llm_response}")
|
101 |
+
st.write(
|
102 |
+
f"π **Carbon Footprint Reduction**: {carbon_reduction:.2f} kg COβ"
|
103 |
+
)
|
104 |
st.markdown("---")
|
105 |
st.write("### π Total Carbon Footprint Reduction π")
|
106 |
st.write(f"π **{total_carbon_reduction:.2f} kg COβ saved**")
|