add toggle info appendix, revise user codes

#2
by zns0327 - opened
Files changed (2) hide show
  1. app.py +26 -11
  2. constants.py +53 -0
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  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
  class SessionManager:
8
  def __init__(self):
@@ -109,9 +109,13 @@ def save_data(session_index, session_manager, service, SHEET_ID):
109
  return "Data has been saved to Google Sheets."
110
 
111
  def login(identification_code):
112
- user_info = user_data.get(identification_code)
113
- if user_info:
114
- return update_content(user_info["group"])
 
 
 
 
115
  else:
116
  return update_content(None)
117
 
@@ -130,17 +134,22 @@ if __name__ == "__main__":
130
  login_status = gr.Textbox(label="Next Tasks", interactive=False)
131
  group = gr.State()
132
 
133
- task = gr.Textbox(label="Task Description",
134
- value = default_task_discription(),
135
- visible=False,
136
- lines=10)
137
 
 
 
 
138
  # initialization of different group contents
139
  group_a_content = gr.Group(visible=False)
140
  group_b_content = gr.Group(visible=False)
141
  group_c_content = gr.Group(visible=False)
142
 
143
 
 
 
144
  def update_content(group):
145
  if group == "A":
146
  return gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), group_a_instructions()
@@ -188,6 +197,9 @@ if __name__ == "__main__":
188
  inputs=[session_index],
189
  outputs=[save_result]
190
  )
 
 
 
191
 
192
  with group_b_content:
193
  with gr.Row():
@@ -206,8 +218,6 @@ if __name__ == "__main__":
206
  )
207
 
208
 
209
-
210
-
211
  evaluate_btn = gr.Button("Evaluate")
212
  evaluation_result = gr.Textbox(label="Evaluation Result")
213
 
@@ -226,6 +236,9 @@ if __name__ == "__main__":
226
  outputs=[save_result]
227
  )
228
 
 
 
 
229
  with group_c_content:
230
  with gr.Row():
231
  create_initial_btn = gr.Button("Create")
@@ -268,6 +281,8 @@ if __name__ == "__main__":
268
  inputs=[session_index],
269
  outputs=[save_result]
270
  )
271
-
 
 
272
 
273
  app.launch(share=True)
 
2
  from utils import *
3
  from save_data import add_new_data, get_sheet_service
4
  from instructions import *
5
+ from constants import SDG_DETAILS, GPT_PROMPT_parallel, GPT_PROMPT_sequential, GPT_PROMPT_reverse_sequential
6
 
7
  class SessionManager:
8
  def __init__(self):
 
109
  return "Data has been saved to Google Sheets."
110
 
111
  def login(identification_code):
112
+ groups = ["A", "B", "C"]
113
+ if not identification_code:
114
+ return update_content(None)
115
+
116
+ user_group_id = int(identification_code)//1000
117
+ if user_group_id in range(3):
118
+ return update_content(groups[user_group_id])
119
  else:
120
  return update_content(None)
121
 
 
134
  login_status = gr.Textbox(label="Next Tasks", interactive=False)
135
  group = gr.State()
136
 
137
+ with gr.Column(visible=False) as task:
138
+ description = gr.Textbox(label="Task Description",
139
+ value = default_task_discription(),
140
+ lines=10)
141
 
142
+ with gr.Accordion(label = "17 Sustainable Development Goals",
143
+ open=False):
144
+ gr.Markdown(SDG_DETAILS)
145
  # initialization of different group contents
146
  group_a_content = gr.Group(visible=False)
147
  group_b_content = gr.Group(visible=False)
148
  group_c_content = gr.Group(visible=False)
149
 
150
 
151
+
152
+
153
  def update_content(group):
154
  if group == "A":
155
  return gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), group_a_instructions()
 
197
  inputs=[session_index],
198
  outputs=[save_result]
199
  )
200
+
201
+ with gr.Accordion(label="Appendix: AI instructions", open=False):
202
+ gr.Markdown(GPT_PROMPT_sequential)
203
 
204
  with group_b_content:
205
  with gr.Row():
 
218
  )
219
 
220
 
 
 
221
  evaluate_btn = gr.Button("Evaluate")
222
  evaluation_result = gr.Textbox(label="Evaluation Result")
223
 
 
236
  outputs=[save_result]
237
  )
238
 
239
+ with gr.Accordion(label="Appendix: AI instructions", open=False):
240
+ gr.Markdown(GPT_PROMPT_parallel)
241
+
242
  with group_c_content:
243
  with gr.Row():
244
  create_initial_btn = gr.Button("Create")
 
281
  inputs=[session_index],
282
  outputs=[save_result]
283
  )
284
+
285
+ with gr.Accordion(label="Appendix: AI instructions", open=False):
286
+ gr.Markdown(GPT_PROMPT_reverse_sequential)
287
 
288
  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
+ """