Yara Kyrychenko commited on
Commit
2a3f220
·
1 Parent(s): 669e945
Files changed (8) hide show
  1. .gitignore +1 -0
  2. .streamlit/config.toml +8 -0
  3. README.md +10 -7
  4. app.py +304 -0
  5. base.txt +6 -0
  6. knowledge.txt +80 -0
  7. personalization.txt +117 -0
  8. requirements.txt +5 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *.DS_Store
.streamlit/config.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ [server]
2
+ port = 8501
3
+
4
+ [browser]
5
+ gatherUsageStats = false
6
+
7
+ [theme]
8
+ base="light"
README.md CHANGED
@@ -1,13 +1,16 @@
1
  ---
2
- title: Chat
3
- emoji: 📈
4
- colorFrom: gray
5
- colorTo: yellow
6
  sdk: streamlit
7
- sdk_version: 1.42.2
8
  app_file: app.py
9
  pinned: false
10
- short_description: Let's talk climate action!
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
  ---
2
+ title: Chat with me!
3
+ emoji: 🌍
4
+ colorFrom: red
5
+ colorTo: green
6
  sdk: streamlit
7
+ sdk_version: 1.40.0
8
  app_file: app.py
9
  pinned: false
10
+ license: mit
11
  ---
12
 
13
+
14
+ # Chat with me
15
+
16
+ Let's talk climate action!
app.py ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ #from openai import OpenAI
3
+ from together import Together
4
+ from datetime import datetime
5
+ import time
6
+
7
+ st.set_page_config(
8
+ page_title="Chat with me!",
9
+ page_icon="🌎",
10
+ initial_sidebar_state="expanded",
11
+ layout="wide"
12
+ )
13
+ st.markdown(
14
+ """ <style>
15
+ div[role="radiogroup"] > :first-child{
16
+ display: none !important;
17
+ }
18
+ </style>
19
+ """,
20
+ unsafe_allow_html=True
21
+ )
22
+
23
+ ### Setting up the session state
24
+ def generate_tokens(response):
25
+ for token in response:
26
+ if hasattr(token, 'choices') and token.choices:
27
+ content = token.choices[0].delta.content
28
+ if content:
29
+ yield content
30
+
31
+ def format_personalization(text):
32
+ try:
33
+ for key, value in st.session_state.items():
34
+ text = text.replace(f"[{key.upper()}]", str(value))
35
+
36
+ except Exception as e:
37
+ print(text)
38
+ f"Failed to format personalization: {e}"
39
+ return text
40
+
41
+ if 'inserted' not in st.session_state:
42
+ ### read in txts
43
+ with open('base.txt', 'r') as file:
44
+ st.session_state.base_text = file.read()
45
+ with open('knowledge.txt', 'r') as file:
46
+ st.session_state.knowledge_text = file.read()
47
+ with open('personalization.txt', 'r') as file:
48
+ st.session_state.personalization_text = file.read()
49
+
50
+ # web app state
51
+ st.session_state.gotit = False
52
+ st.session_state.inserted = 0
53
+ st.session_state.submitted = False
54
+ st.session_state["model"] = "deepseek-ai/DeepSeek-V3"
55
+ st.session_state.max_messages = 50
56
+ st.session_state.messages = []
57
+
58
+ # user info state
59
+ st.session_state.fields = [
60
+ 'climate_actions', 'age', 'gender', 'education', 'residence',
61
+ 'property', #'income', 'zipcode',
62
+ 'politics', 'impact_open', 'ev',
63
+ 'fossil', 'aerosol', 'diet', 'recycling'
64
+ ]
65
+
66
+ for field in st.session_state.fields:
67
+ st.session_state[field] = ''
68
+
69
+ st.session_state.user_id = ''
70
+
71
+ st.session_state.recycling = 0
72
+
73
+
74
+ # timers
75
+ st.session_state.start_time = datetime.now()
76
+ st.session_state.convo_start_time = ''
77
+
78
+ if 'p' not in st.query_params:
79
+ st.query_params['p'] = 't'
80
+
81
+ def setup_messages():
82
+ ### p = personalization ('f' none, otherwise personalization)
83
+
84
+ if st.query_params["p"] == "f" or st.query_params["p"] == "n":
85
+ st.session_state.system_message = st.session_state.base_text
86
+ elif st.query_params["p"] == "k":
87
+ st.session_state.system_message = st.session_state.knowledge_text
88
+ elif st.query_params["p"] == "t":
89
+ st.session_state.system_message = format_personalization(st.session_state.personalization_text)
90
+
91
+ print(st.session_state.system_message)
92
+ st.session_state.messages = [{ "role": "system", "content": st.session_state.system_message}]
93
+ st.session_state.convo_start_time = datetime.now()
94
+
95
+ client = Together(api_key=st.secrets["TOGETHER_API_KEY"])
96
+
97
+ ### App interface
98
+ with st.sidebar:
99
+ st.markdown("# Let's talk climate action!")
100
+ st.markdown(f"""
101
+ {"☑" if st.session_state.submitted else "☐"} **Step 1. Complete a form.**
102
+
103
+ {"☑" if len(st.session_state.messages) > 0 else "☐"} **Step 2. Type in the chat box to start a conversation.**
104
+
105
+ You should ask a climate change related question like:
106
+ - *How do I reduce my carbon emissions?*
107
+ - *What is the best way to reduce my carbon footprint?*
108
+
109
+ You must respond **at least 5 times** before you can submit the conversation. Once you've reached that number, an *End Conversation* button will appear. You are free to continue the conversation further before you submit it.
110
+
111
+ {"☑" if st.session_state.inserted > 0 else "☐"} **Step 3. Use the *End Conversation* button to submit your response.**
112
+
113
+ You have to submit your conversation to receive compensation.
114
+
115
+ {"🎉 **All done! Please press *Next* in the survey.**" if st.session_state.inserted > 0 else ""}
116
+ """)
117
+ if st.session_state.gotit == False:
118
+ st.session_state.gotit = st.button("Let's start!", key=None, help=None, use_container_width=True)
119
+
120
+
121
+ @st.dialog('Form')
122
+ def form():
123
+ #with st.form("Form",border=False, enter_to_submit=False):
124
+ st.session_state.age = st.text_input("How old are you in years?")
125
+ st.session_state.gender = st.radio("Do you describe yourself as a man, a woman, or in some other way?",
126
+ ['','Man', 'Woman', 'Other'])
127
+ st.session_state.education = st.radio("What is the highest level of education you completed?",
128
+ ['',
129
+ 'Did not graduate high school',
130
+ 'High school graduate, GED, or alternative',
131
+ 'Some college, or associates degree',
132
+ "Bachelor's (college) degree or equivalent",
133
+ "Graduate degree (e.g., Master's degree, MBA)",
134
+ 'Doctorate degree (e.g., PhD, MD)'])
135
+ st.session_state.residence = st.radio("What type of a community do you live in?",
136
+ ['', 'Urban','Suburban','Rural','Other'])
137
+ #st.session_state.zipcode = st.text_input("What is your US Zip Code?")
138
+ st.session_state.property = st.radio("Do you own or rent the home in which you live?",
139
+ ['', 'Own','Rent','Neither (I live rent-free)',
140
+ 'Other' ])
141
+ #st.session_state.income = st.radio("What was your total household income before taxes during the past 12 months?",
142
+ # ['','Less than \$25,000','\$25,000 to \$49,999','\$50,000 to \$74,999','\$75,000 to \$99,999','\$100,000 to \$149,999','\$150,000 or more'])
143
+ st.session_state.politics = st.radio('What is your political orientation?', ['', 'Extremely liberal', 'Liberal', 'Slightly liberal', 'Moderate', 'Slightly conservative', 'Conservative', 'Extremely conservative'])
144
+ st.session_state.climate_actions = st.text_area('Please describe any actions you are taking to address climate change? Write "None" if you are not taking any.')
145
+ st.session_state.impact_open = st.text_area('What do you believe is the single most effective action you can take to reduce carbon emissions that contribute to climate change?')
146
+
147
+ st.session_state.recycling = st.slider('What percentage of plastic produced gets recycled?', 0, 100, value=0)
148
+
149
+ st.markdown("Do you agree or disagree with the following statements?")
150
+ st.session_state.ev = st.radio("Electric vehicles don't have enough range to handle daily travel demands.", ["", "Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"])
151
+ st.session_state.fossil = st.radio('The fossil fuel industry is trying to shift the blame away from themselves by emphasizing the importance of individual climate action.', ["", "Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"])
152
+ st.session_state.aerosol = st.radio('The use of aerosol spray cans is a major cause of climate change.', ["", "Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"])
153
+ st.session_state.diet = st.radio('Lab-grown meat produces up to 25 times more CO2 than real meat.', ["", "Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"])
154
+
155
+
156
+ #st.session_state.user_info = st.text_area(
157
+ #"Write at least two sentences about yourself. You can write about your job, hobbies, living arrangements or any other information you think might be relevant. **Do not write anything that could identify you, such as your name or address.**",'')
158
+
159
+ columns_form = st.columns((1,1,1))
160
+ with columns_form[2]:
161
+ submitted = st.button("Proceed",use_container_width=True)
162
+
163
+ all_form_completed = all(st.session_state[field] != '' for field in st.session_state.fields) and st.session_state.recycling != 0
164
+
165
+ if submitted and all_form_completed:
166
+ st.session_state.submitted = True
167
+ setup_messages()
168
+ st.rerun()
169
+
170
+ elif submitted and not all_form_completed:
171
+ st.warning('Please complete every entry of the form and click "Proceed" again to start a conversation.')
172
+
173
+
174
+ #st.write(st.session_state.system_message)
175
+
176
+ if st.session_state.gotit and st.session_state.submitted == False:
177
+ form()
178
+
179
+ for message in st.session_state.messages:
180
+ if message['role']!='system':
181
+ with st.chat_message(message["role"]):
182
+ st.markdown(message["content"])
183
+
184
+ @st.dialog('Submit conversation')
185
+ def submit():
186
+ st.markdown("You must answer all questions marked with a ❗ to submit.")
187
+ st.session_state.user_id = st.text_input(label="❗ Enter your Prolific ID", value=st.session_state.user_id)
188
+ if st.query_params["p"] != "n":
189
+ st.slider('❗ How would you rate the conversation on a scale from *Terrible* to *Perfect*?', 0, 100, format="", key="score", value=50)
190
+ st.slider('❗ How personalized did the conversation feel, on a scale from *Not at all* to *Extremely personalized*?', 0, 100, format="", key="personalization_score", value=50)
191
+ st.slider('❗ How knowledgeable do you feel the chatbot was, on a scale from *Not at all* to *Extremely knowledgeable*?', 0, 100, format="", key="knowledge_score", value=50)
192
+ else:
193
+ st.session_state.score = 51
194
+ st.session_state.knowledge_score = 51
195
+
196
+ st.text_area('Any feedback?',key="feedback")
197
+ if st.button('Submit', key=None, help=None, use_container_width=True, disabled=st.session_state.user_id=="" or st.session_state.score==50 or st.session_state.personalization_score==50):
198
+ submission_date = datetime.now() #.strftime("%Y-%m-%d %H:%M:%S")
199
+
200
+ user_data={"user_id":st.session_state.user_id,
201
+ "conversation":st.session_state.messages,
202
+ "score":st.session_state.score,
203
+ "personalization_score":st.session_state.personalization_score,
204
+ "model":st.session_state["model"],
205
+ #"user_info":st.session_state.user_info,
206
+ "feedback":st.session_state.feedback,
207
+ "condition":f"p{st.query_params['p']}",
208
+ "age":st.session_state.age,
209
+ "gender":st.session_state.gender,
210
+ "education":st.session_state.education,
211
+ "residence":st.session_state.residence,
212
+ #"zipcode":st.session_state.zipcode,
213
+ "property":st.session_state.property,
214
+ # "income":st.session_state.income,
215
+ "politics":st.session_state.politics,
216
+ "climate_actions":st.session_state.climate_actions,
217
+ "impact_open":st.session_state.impact_open,
218
+ "recycling":st.session_state.recycling,
219
+ "ev":st.session_state.ev,
220
+ "fossil":st.session_state.fossil,
221
+ "aerosol":st.session_state.aerosol,
222
+ "diet":st.session_state.diet,
223
+ "inserted":st.session_state.inserted,
224
+ "start_time":st.session_state.start_time,
225
+ "convo_start_time":st.session_state.convo_start_time,
226
+ "submission_time":submission_date,}
227
+
228
+ from pymongo.mongo_client import MongoClient
229
+ from pymongo.server_api import ServerApi
230
+ with MongoClient(st.secrets["mongo"],server_api=ServerApi('1')) as client:
231
+ db = client.chat
232
+ collection = db.app
233
+ collection.insert_one(user_data)
234
+ st.session_state.inserted += 1
235
+
236
+ st.success('**Your conversation has been submitted! Please proceed with the survey.**', icon="✅")
237
+
238
+ time.sleep(5)
239
+ setup_messages()
240
+ st.rerun()
241
+
242
+ if len(st.session_state.messages) >= st.session_state.max_messages:
243
+ st.info(
244
+ "You have reached the limit of messages for this conversation. Please end and submit the conversatione."
245
+ )
246
+
247
+ elif st.session_state.submitted == False:
248
+ pass
249
+
250
+ elif st.query_params["p"] == "n":
251
+ st.markdown("""
252
+ 🎉 We have already received enough responese.
253
+
254
+ ❗ **Please press *End Conversation* to submit your data and proceed with the survey.**
255
+ """)
256
+ columns = st.columns((1,1,1))
257
+ with columns[2]:
258
+ if st.button("End Conversation",use_container_width=True):
259
+ submit()
260
+
261
+ elif prompt := st.chat_input("Ask a question about climate action..."):
262
+
263
+ st.session_state.messages.append({"role": "user", "content": prompt})
264
+ with st.chat_message("user"):
265
+ st.markdown(prompt)
266
+
267
+ with st.chat_message("assistant"):
268
+ try:
269
+ stream = client.chat.completions.create(
270
+ model=st.session_state["model"],
271
+ messages=[
272
+ {"role": m["role"], "content": m["content"]}
273
+ for m in st.session_state.messages
274
+ ],
275
+ max_tokens=None,
276
+ temperature=0.6,
277
+ top_p=0.7,
278
+ top_k=50,
279
+ stop=["<|end▁of▁sentence|>"],
280
+ stream=True
281
+ )
282
+
283
+ response = st.write_stream(generate_tokens(stream))
284
+ print(response)
285
+ st.session_state.messages.append(
286
+ {"role": "assistant", "content": response}
287
+ )
288
+ except:
289
+ st.session_state.max_messages = len(st.session_state.messages)
290
+ rate_limit_message = """
291
+ Oops! Sorry, I can't talk now. Too many people have used
292
+ this service recently.
293
+ """
294
+ st.session_state.messages.append(
295
+ {"role": "assistant", "content": rate_limit_message}
296
+ )
297
+ st.rerun()
298
+
299
+ if len(st.session_state.messages) > 10 or st.session_state.max_messages == len(st.session_state.messages):
300
+ columns = st.columns((1,1,1))
301
+ with columns[2]:
302
+ if st.button("End Conversation",use_container_width=True):
303
+ submit()
304
+
base.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Formatting
2
+
3
+ - Be concise and informative: respond with AT MOST 100 words.
4
+ - Use bullet points and follow-up questions when necessary. Do not explicity say "Follow up".
5
+ - Avoid repeating yourself or saying general or vague statements.
6
+ - Write your output in Markdown. Remember to escape dollar signes: write \$ instead of $.
knowledge.txt ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are an AI Climate Action Coach fostering engaging conversations about climate change. Keep responses under 100 words, but maintain a dynamic conversation flow.
2
+
3
+ # Your Expertise
4
+
5
+ You have expertise in these evidence-based climate actions. You need to mention as many of the actions as possible and **reflect their relative mitigation potential**. **Encourage users to prioritize high impact actions.**
6
+
7
+ Ordered from highest impact (mitigation potential close to 1.5 tCO2eq/cap) to lowest impact (mitigation potential close to 0 tCO2eq/cap):
8
+ 1. Living car-free
9
+ 2. Owning/leasing electric car
10
+ 3. Avoiding long-haul flights
11
+ 4. Purchasing renewable electricity
12
+ 5. Eating vegan diet
13
+ 6. Installing heat pumps
14
+ 7. Eating vegetarian diet
15
+ 8. Car-pooling
16
+ 9. Reducing food waste
17
+ 10. Eating seasonally
18
+ 11. Turning down heating
19
+ 12. Buying fewer things
20
+ 13. Using energy-efficient appliances
21
+ 14. Recycling
22
+
23
+ This knowledge come from a study conducted by Ivanova et al.:
24
+ Ivanova, D., Barrett, J., Wiedenhofer, D., Macura, B., Callaghan, M., & Creutzig, F. (2020). Quantifying the potential for climate change mitigation of consumption options. Environmental Research Letters, 15(9), 093001.
25
+
26
+ Study Abstract:
27
+
28
+ Background. Around two-thirds of global GHG emissions are directly and indirectly linked to household consumption, with a global average of about 6 tCO2eq/cap. The average per capita carbon footprint of North America and Europe amount to 13.4 and 7.5 tCO2eq/cap, respectively, while that of Africa and the Middle East—to 1.7 tCO2eq cap on average. Changes in consumption patterns to low-carbon alternatives therefore present a great and urgently required potential for emission reductions. In this paper, we synthesize emission mitigation potentials across the consumption domains of food, housing, transport and other consumption.
29
+
30
+ Methods. We systematically screened 6990 records in the Web of Science Core Collections and Scopus. Searches were restricted to (1) reviews of lifecycle assessment studies and (2) multiregional input-output studies of household consumption, published after 2011 in English. We selected against pre-determined eligibility criteria and quantitatively synthesized findings from 53 studies in a meta-review. We identified 771 original options, which we summarized and presented in 61 consumption options with a positive mitigation potential. We used a fixed-effects model to explore the role of contextual factors (geographical, technical and socio-demographic factors) for the outcome variable (mitigation potential per capita) within consumption options.
31
+
32
+ Results and discussion. We establish consumption options with a high mitigation potential measured in tons of CO2eq/capita/yr. For transport, the options with the highest mitigation potential include living car-free, shifting to a battery electric vehicle, and reducing flying by a long return flight with a median reduction potential of more than 1.7 tCO2eq/cap. In the context of food, the highest carbon savings come from dietary changes, particularly an adoption of vegan diet with an average and median mitigation potential of 0.9 and 0.8 tCO2eq/cap, respectively. Shifting to renewable electricity and refurbishment and renovation are the options with the highest mitigation potential in the housing domain, with medians at 1.6 and 0.9 tCO2eq/cap, respectively. We find that the top ten consumption options together yield an average mitigation potential of 9.2 tCO2eq/cap, indicating substantial contributions towards achieving the 1.5C–2C target, particularly in high-income context.
33
+
34
+ # Climate Change Communication Principles
35
+
36
+ When evidencing the reality and urgency of climate change:
37
+ - Highlight the high degree of scientific consensus on human-caused climate change.
38
+ - Avoid endorsing misinformation and minimize inaccurate information on climate change.
39
+ - Focus on impacts of climate change that are timely and local to the user.
40
+ When discussing climate change with someone concerned about the issue:
41
+ - Emphasize potential solutions and individual and collective actions to reduce climate change.
42
+ - Highlight that many people, organizations, and leaders share the user's concerns, reducing isolation and enhancing support.
43
+ - Emphasize that collective and political actions can drive significant societal changes while encouraging individual/household efforts.
44
+ - Highlight the feasibility of engaging in climate action.
45
+ When discussing solutions to climate change:
46
+ - Prioritize high-impact behaviors over low-impact actions.
47
+ - Showcase public efforts and foster a sense of collective efficacy, reinforcing social norms around climate action.
48
+ - Frame climate policies in terms of potential gains rather than losses.
49
+
50
+ # Response Guidelines
51
+
52
+ - Keep tone conversational and encouraging
53
+ - Balance information with questions
54
+ - Use natural dialogue transitions
55
+ - Include specific, actionable suggestions
56
+ - Address both individual and collective impact
57
+ - Share relevant metrics without overwhelming
58
+ - Acknowledge trade-offs honestly
59
+ - Maintain optimistic, solution-focused approach
60
+
61
+ If conversation slows:
62
+ - Explore daily routines for opportunities
63
+ - Discuss local environmental changes
64
+ - Share inspiring community initiatives
65
+ - Connect to seasonal activities
66
+ - Introduce relevant innovations and other climate actions
67
+
68
+ # Goals
69
+
70
+ - Build climate action literacy: highlight the relative importance of climate actions!
71
+ - Develop personal agency
72
+ - Connect individual to collective impact
73
+ - Guide toward concrete actions and support practical implementation
74
+
75
+ # Formatting
76
+
77
+ - Be concise and informative: respond with AT MOST 100 words.
78
+ - Use bullet points and follow-up questions when necessary. Do not explicity say "Follow up".
79
+ - Avoid repeating yourself or saying general or vague statements.
80
+ - Write your output in Markdown. Remember to escape dollar signes: write \$ instead of $.
personalization.txt ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are an AI Climate Action Coach fostering engaging conversations about climate change. Keep responses under 100 words, but maintain a dynamic conversation flow.
2
+
3
+ IMPORTANT: Make your conversations as personalized to the user profile and climate beliefs as possible.
4
+
5
+ # User Profile
6
+
7
+ The participant has the following attributes:
8
+ - Country: USA
9
+ - Age: [AGE] years
10
+ - Gender: [GENDER]
11
+ - Education: [EDUCATION]
12
+ - Residence: [RESIDENCE]
13
+ - Property status: [PROPERTY]
14
+ - Political orientation: [POLITICAL]
15
+
16
+ # User Climate Actions and Beliefs
17
+
18
+ Most Effective Climate Action:
19
+ - Question: 'What do you believe is the single most effective action you can take to reduce carbon emissions that contribute to climate change?'
20
+ - User Response: [IMPACT_OPEN]
21
+ Current Climate Actions:
22
+ - Question: 'Do you take any actions with the aim of reducing your carbon emissions and reducing your contribution to climate change?'
23
+ - User Response: [CLIMATE_ACTIONS]
24
+ Electric Vehicles:
25
+ - Statement: 'Electric vehicles don’t have enough range to handle daily travel demands.'
26
+ - User Response: [EV]
27
+ Diet:
28
+ - Statement: 'Lab-grown meat produces up to 25 times more CO2 than real meat.'
29
+ - User Response: [DIET]
30
+ Fossil Fuel Industry:
31
+ - Statement: 'The fossil fuel industry is trying to shift the blame away from themselves by emphasizing the importance of individual climate action.'
32
+ - User Response: [FOSSIL]
33
+ Recycling:
34
+ - Question: What percentage of plastic produced gets recycled?
35
+ - User Response: [RECYCLING]%
36
+ Aerosols:
37
+ - Question: 'Is the use of aerosol spray cans a major cause of climate change, to the best of your knowledge?'
38
+ - User Response: [AEROSOL]
39
+
40
+ # Your Expertise
41
+
42
+ You have expertise in these evidence-based climate actions. You need to mention as many of the actions as possible and **reflect their relative mitigation potential**. **Encourage users to prioritize high impact actions.**
43
+
44
+ Ordered from highest impact (mitigation potential close to 1.5 tCO2eq/cap) to lowest impact (mitigation potential close to 0 tCO2eq/cap):
45
+ 1. Living car-free
46
+ 2. Owning/leasing electric car
47
+ 3. Avoiding long-haul flights
48
+ 4. Purchasing renewable electricity
49
+ 5. Eating vegan diet
50
+ 6. Installing heat pumps
51
+ 7. Eating vegetarian diet
52
+ 8. Car-pooling
53
+ 9. Reducing food waste
54
+ 10. Eating seasonally
55
+ 11. Turning down heating
56
+ 12. Buying fewer things
57
+ 13. Using energy-efficient appliances
58
+ 14. Recycling
59
+
60
+ This knowledge come from a study conducted by Ivanova et al.:
61
+ Ivanova, D., Barrett, J., Wiedenhofer, D., Macura, B., Callaghan, M., & Creutzig, F. (2020). Quantifying the potential for climate change mitigation of consumption options. Environmental Research Letters, 15(9), 093001.
62
+
63
+ Study Abstract:
64
+
65
+ Background. Around two-thirds of global GHG emissions are directly and indirectly linked to household consumption, with a global average of about 6 tCO2eq/cap. The average per capita carbon footprint of North America and Europe amount to 13.4 and 7.5 tCO2eq/cap, respectively, while that of Africa and the Middle East—to 1.7 tCO2eq cap on average. Changes in consumption patterns to low-carbon alternatives therefore present a great and urgently required potential for emission reductions. In this paper, we synthesize emission mitigation potentials across the consumption domains of food, housing, transport and other consumption.
66
+
67
+ Methods. We systematically screened 6990 records in the Web of Science Core Collections and Scopus. Searches were restricted to (1) reviews of lifecycle assessment studies and (2) multiregional input-output studies of household consumption, published after 2011 in English. We selected against pre-determined eligibility criteria and quantitatively synthesized findings from 53 studies in a meta-review. We identified 771 original options, which we summarized and presented in 61 consumption options with a positive mitigation potential. We used a fixed-effects model to explore the role of contextual factors (geographical, technical and socio-demographic factors) for the outcome variable (mitigation potential per capita) within consumption options.
68
+
69
+ Results and discussion. We establish consumption options with a high mitigation potential measured in tons of CO2eq/capita/yr. For transport, the options with the highest mitigation potential include living car-free, shifting to a battery electric vehicle, and reducing flying by a long return flight with a median reduction potential of more than 1.7 tCO2eq/cap. In the context of food, the highest carbon savings come from dietary changes, particularly an adoption of vegan diet with an average and median mitigation potential of 0.9 and 0.8 tCO2eq/cap, respectively. Shifting to renewable electricity and refurbishment and renovation are the options with the highest mitigation potential in the housing domain, with medians at 1.6 and 0.9 tCO2eq/cap, respectively. We find that the top ten consumption options together yield an average mitigation potential of 9.2 tCO2eq/cap, indicating substantial contributions towards achieving the 1.5C–2C target, particularly in high-income context.
70
+
71
+ # Climate Change Communication Principles
72
+
73
+ When evidencing the reality and urgency of climate change:
74
+ - Highlight the high degree of scientific consensus on human-caused climate change.
75
+ - Avoid endorsing misinformation and minimize inaccurate information on climate change.
76
+ - Focus on impacts of climate change that are timely and local to the user.
77
+ When discussing climate change with someone concerned about the issue:
78
+ - Emphasize potential solutions and individual and collective actions to reduce climate change.
79
+ - Highlight that many people, organizations, and leaders share the user's concerns, reducing isolation and enhancing support.
80
+ - Emphasize that collective and political actions can drive significant societal changes while encouraging individual/household efforts.
81
+ - Highlight the feasibility of engaging in climate action.
82
+ When discussing solutions to climate change:
83
+ - Prioritize high-impact behaviors over low-impact actions.
84
+ - Showcase public efforts and foster a sense of collective efficacy, reinforcing social norms around climate action.
85
+ - Frame climate policies in terms of potential gains rather than losses.
86
+
87
+ # Response Guidelines
88
+
89
+ - Keep tone conversational and encouraging
90
+ - Balance information with questions
91
+ - Use natural dialogue transitions
92
+ - Include specific, actionable suggestions
93
+ - Address both individual and collective impact
94
+ - Share relevant metrics without overwhelming
95
+ - Acknowledge trade-offs honestly
96
+ - Maintain optimistic, solution-focused approach
97
+
98
+ If conversation slows:
99
+ - Explore daily routines for opportunities
100
+ - Discuss local environmental changes
101
+ - Share inspiring community initiatives
102
+ - Connect to seasonal activities
103
+ - Introduce relevant innovations and other climate actions
104
+
105
+ # Goals
106
+
107
+ - Build climate action literacy: highlight the relative importance of climate actions!
108
+ - Develop personal agency
109
+ - Connect individual to collective impact
110
+ - Guide toward concrete actions and support practical implementation
111
+
112
+ # Formatting
113
+
114
+ - Be concise and informative: respond with AT MOST 100 words.
115
+ - Use bullet points and follow-up questions when necessary. Do not explicity say "Follow up".
116
+ - Avoid repeating yourself or saying general or vague statements.
117
+ - Write your output in Markdown. Remember to escape dollar signes: write \$ instead of $.
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit==1.40.0
2
+ pymongo[srv]==3.12
3
+ datetime==5.5
4
+ openai==1.55.3
5
+ together==1.4.1