周倬孚 commited on
Commit
fef4c91
·
2 Parent(s): ec8338e 311588a

Merge branch 'main' into pr/1

Browse files
Files changed (2) hide show
  1. app.py +27 -11
  2. constants.py +53 -0
app.py CHANGED
@@ -3,7 +3,7 @@ from utils import *
3
  from save_data import add_new_data, get_sheet_service
4
  from instructions import *
5
  from user_groups import user_data
6
-
7
 
8
 
9
  class SessionManager:
@@ -121,9 +121,13 @@ def save_data(session_index, session_manager, service, SHEET_ID):
121
  return "Data has been saved to Google Sheets."
122
 
123
  def login(identification_code):
124
- user_info = user_data.get(identification_code)
125
- if user_info:
126
- return update_content(user_info["group"])
 
 
 
 
127
  else:
128
  return update_content(None)
129
 
@@ -150,17 +154,22 @@ if __name__ == "__main__":
150
  login_status = gr.Textbox(label="Next Tasks", interactive=False)
151
  group = gr.State()
152
 
153
- task = gr.Textbox(label="Task Description",
154
- value = default_task_discription(),
155
- visible=False,
156
- lines=10)
157
 
 
 
 
158
  # initialization of different group contents
159
  group_a_content = gr.Group(visible=False)
160
  group_b_content = gr.Group(visible=False)
161
  group_c_content = gr.Group(visible=False)
162
 
163
 
 
 
164
  def update_content(group):
165
  if group == "A":
166
  return gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), group_a_instructions()
@@ -219,6 +228,9 @@ if __name__ == "__main__":
219
  inputs=[session_index],
220
  outputs=[save_result]
221
  )
 
 
 
222
 
223
  with group_b_content:
224
  with gr.Row():
@@ -265,7 +277,8 @@ if __name__ == "__main__":
265
  outputs=[save_result]
266
  )
267
 
268
-
 
269
 
270
  with group_c_content:
271
  with gr.Row():
@@ -324,5 +337,8 @@ if __name__ == "__main__":
324
  inputs=[session_index],
325
  outputs=[save_result]
326
  )
327
-
328
- app.launch(share=True)
 
 
 
 
3
  from save_data import add_new_data, get_sheet_service
4
  from instructions import *
5
  from user_groups import user_data
6
+ from constants import SDG_DETAILS, GPT_PROMPT_parallel, GPT_PROMPT_sequential, GPT_PROMPT_reverse_sequential
7
 
8
 
9
  class SessionManager:
 
121
  return "Data has been saved to Google Sheets."
122
 
123
  def login(identification_code):
124
+ groups = ["A", "B", "C"]
125
+ if not identification_code:
126
+ return update_content(None)
127
+
128
+ user_group_id = int(identification_code)//1000
129
+ if user_group_id in range(3):
130
+ return update_content(groups[user_group_id])
131
  else:
132
  return update_content(None)
133
 
 
154
  login_status = gr.Textbox(label="Next Tasks", interactive=False)
155
  group = gr.State()
156
 
157
+ with gr.Column(visible=False) as task:
158
+ description = gr.Textbox(label="Task Description",
159
+ value = default_task_discription(),
160
+ lines=10)
161
 
162
+ with gr.Accordion(label = "17 Sustainable Development Goals",
163
+ open=False):
164
+ gr.Markdown(SDG_DETAILS)
165
  # initialization of different group contents
166
  group_a_content = gr.Group(visible=False)
167
  group_b_content = gr.Group(visible=False)
168
  group_c_content = gr.Group(visible=False)
169
 
170
 
171
+
172
+
173
  def update_content(group):
174
  if group == "A":
175
  return gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), group_a_instructions()
 
228
  inputs=[session_index],
229
  outputs=[save_result]
230
  )
231
+
232
+ with gr.Accordion(label="Appendix: AI instructions", open=False):
233
+ gr.Markdown(GPT_PROMPT_sequential)
234
 
235
  with group_b_content:
236
  with gr.Row():
 
277
  outputs=[save_result]
278
  )
279
 
280
+ with gr.Accordion(label="Appendix: AI instructions", open=False):
281
+ gr.Markdown(GPT_PROMPT_parallel)
282
 
283
  with group_c_content:
284
  with gr.Row():
 
337
  inputs=[session_index],
338
  outputs=[save_result]
339
  )
340
+
341
+ with gr.Accordion(label="Appendix: AI instructions", open=False):
342
+ gr.Markdown(GPT_PROMPT_reverse_sequential)
343
+
344
+ app.launch(share=True)
constants.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SDG_DETAILS = """
2
+ 1. No Poverty: End poverty in all its forms everywhere.
3
+ 2. Zero Hunger: End hunger, achieve food security and improved nutrition, and promote sustainable agriculture.
4
+ 3. Good Health and Well-being: Ensure healthy lives and promote well-being for all at all ages.
5
+ 4. Quality Education: Ensure inclusive and equitable quality education and promote lifelong learning opportunities for all.
6
+ 5. Gender Equality: Achieve gender equality and empower all women and girls.
7
+ 6. Clean Water and Sanitation: Ensure availability and sustainable management of water and sanitation for all.
8
+ 7. Affordable and Clean Energy: Ensure access to affordable, reliable, sustainable and modern energy for all.
9
+ 8. Decent Work and Economic Growth: Promote sustained, inclusive and sustainable economic growth, full and productive employment and decent work for all.
10
+ 9. Industry, Innovation and Infrastructure: Build resilient infrastructure, promote inclusive and sustainable industrialization and foster innovation.
11
+ 10. Reduced Inequality: Reduce inequality within and among countries.
12
+ 11. Sustainable Cities and Communities: Make cities and human settlements inclusive, safe, resilient and sustainable.
13
+ 12. Responsible Consumption and Production: Ensure sustainable consumption and production patterns.
14
+ 13. Climate Action: Take urgent action to combat climate change and its impacts.
15
+ 14. Life Below Water: Conserve and sustainably use the oceans, seas and marine resources for sustainable development.
16
+ 15. Life on Land: Protect, restore and promote sustainable use of terrestrial ecosystems, sustainably manage forests, combat desertification, and halt and reverse land degradation and halt biodiversity loss.
17
+ 16. Peace and Justice Strong Institutions: Promote peaceful and inclusive societies for sustainable development, provide access to justice for all and build effective, accountable and inclusive institutions at all levels.
18
+ 17. Partnerships to achieve the Goal: Strengthen the means of implementation and revitalize the Global Partnership for Sustainable Development.
19
+ """
20
+
21
+ GPT_PROMPT_parallel="""
22
+ For AI generted/modified parts, our base model is GPT-3.5-turbo.
23
+
24
+ For direct generation, we use instructions like following:
25
+ "Given the task as: [task_description], provide an answer: "
26
+
27
+ For the merging, we use instructions like following:
28
+ "Given the task as: [task_description], there are two answers provided:
29
+ The first answer: [human_text]
30
+ The second answer: [ai_text]
31
+ Merge the two answers into one in a coherent way: "
32
+ """
33
+
34
+ GPT_PROMPT_sequential="""
35
+ For AI generted/modified parts, our base model is GPT-3.5-turbo.
36
+
37
+ For the modification, we use instructions like following:
38
+ "Given the task as :[task_description, the human answer is: [human_text]
39
+ Provide an answer of your own but make sure it is coherent and should be based on the human answer: "
40
+ """
41
+
42
+ GPT_PROMPT_reverse_sequential="""
43
+ For AI generted/modified parts, our base model is GPT-3.5-turbo.
44
+
45
+ For direct generation, we use instructions like following:
46
+ "Given the task as: [task_description], provide an answer: "
47
+
48
+ For the merging, we use instructions like following:
49
+ "Given the task as: [task_description], there are two answers provided:
50
+ The first answer: [human_text]
51
+ The second answer: [ai_text]
52
+ Merge the two answers into one in a coherent way: "
53
+ """