Mujtaba29 commited on
Commit
a809d45
Β·
verified Β·
1 Parent(s): f1f08fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -117
app.py CHANGED
@@ -19,122 +19,6 @@ carbon_reduction_data = {
19
  "Tires": 8.0,
20
  }
21
 
22
- # Custom CSS for colors and layout
23
- st.markdown(
24
- """
25
- <style>
26
- body {
27
- background-color: #f5f5f5;
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: #dceefb;
37
- border-radius: 10px;
38
- }
39
- </style>
40
- """,
41
- unsafe_allow_html=True,
42
- )
43
-
44
- # Sidebar for navigation
45
- st.sidebar.title("🌍 RecycleSmart-PK")
46
- st.sidebar.image(
47
- "https://via.placeholder.com/300x200?text=RecycleSmart+Logo",
48
- use_container_width=True,
49
- )
50
- st.sidebar.markdown("### Navigation")
51
- section = st.sidebar.radio(
52
- "Choose a section:", ["Home", "Recycle Suggestions"]
53
- )
54
-
55
- # Main Content
56
- if section == "Home":
57
- st.title("♻️ Welcome to RecycleSmart-PK!")
58
- st.image(
59
- "https://via.placeholder.com/800x400?text=Recycle+Smartly%2C+Save+Our+Planet",
60
- use_container_width=True,
61
- )
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:
83
- total_carbon_reduction = 0
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**")
107
- st.success("πŸŽ‰ Great job contributing to a greener planet!")
108
- else:
109
- st.error("❗ Please select at least one item and specify its quantity.")
110
-
111
-
112
-
113
-
114
-
115
-
116
- """
117
- import os
118
- import streamlit as st
119
- from groq import Groq
120
-
121
- # Set the Groq API key
122
- os.environ["GROQ_API_KEY"] = "key"
123
-
124
- # Initialize Groq client
125
- client = Groq(api_key=os.environ.get("key"))
126
-
127
- # Carbon footprint reduction data (kg CO2 per kg recycled)
128
- carbon_reduction_data = {
129
- "Plastic Bottles": 3.8,
130
- "Glass Bottles": 0.5,
131
- "Metal Cans": 9.0,
132
- "Old Clothes": 2.0,
133
- "Paper and Cardboard": 1.3,
134
- "E-Waste": 15.0,
135
- "Tires": 8.0,
136
- }
137
-
138
  # Function to call Groq LLM
139
  def get_recycling_suggestions_from_groq(item, quantity):
140
  prompt = (
@@ -207,4 +91,3 @@ if st.button("Ask Groq"):
207
  st.write(follow_up_response)
208
  else:
209
  st.error("Please enter a question.")
210
- """
 
19
  "Tires": 8.0,
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  # Function to call Groq LLM
23
  def get_recycling_suggestions_from_groq(item, quantity):
24
  prompt = (
 
91
  st.write(follow_up_response)
92
  else:
93
  st.error("Please enter a question.")