Yuanjun commited on
Commit
e116042
·
unverified ·
2 Parent(s): 6dafe7c eed6b20

Merge pull request #3 from ZnS77/feature/task-description

Browse files
Files changed (5) hide show
  1. .gitignore +2 -1
  2. app.py +12 -7
  3. constants.py +1 -0
  4. instructions.py +24 -3
  5. utils.py +0 -1
.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  .env
2
- *.json
 
 
1
  .env
2
+ *.json
3
+ ensemble-ai/
app.py CHANGED
@@ -3,7 +3,7 @@ from utils import *
3
  from save_data import add_or_update_row_at_fixed_position, get_sheet_service
4
  from instructions import *
5
  from user_groups import user_data
6
- from constants import SDG_DETAILS, WORD_LIMIT_MIN, GROUP_SEPERATION, LOCAL_PARAMS
7
  from html_codes import *
8
 
9
  class SessionManager:
@@ -142,6 +142,8 @@ def word_limit_validation(human_input):
142
  words = human_input.split()
143
  if len(words) < WORD_LIMIT_MIN:
144
  return f"Error: Please enter at least 100 words."
 
 
145
  return None
146
 
147
  def on_textbox_change(session_index, session_manager, service, SHEET_ID):
@@ -176,15 +178,18 @@ if __name__ == "__main__":
176
  login_status = gr.Textbox(label="Next Tasks", interactive=False)
177
  group = gr.State()
178
 
179
- with gr.Column(visible=False) as task:
180
  description = gr.Textbox(label="Task Description",
181
- value = default_task_discription(),
182
  interactive=False,
183
  lines=12)
184
 
185
  with gr.Accordion(label = "Click to See 17 SDGs",
186
  open=False):
187
  gr.Markdown(SDG_DETAILS)
 
 
 
188
  # initialization of different group contents
189
  group_a_content = gr.Group(visible=False, elem_id="group-a")
190
  group_b_content = gr.Group(visible=False, elem_id="group-b")
@@ -203,7 +208,7 @@ if __name__ == "__main__":
203
  else:
204
  return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), invalid_group()
205
 
206
- login_button.click(login, inputs=identification_code, outputs=[task, group_a_content, group_b_content, group_c_content, login_status])
207
 
208
 
209
 
@@ -220,7 +225,7 @@ if __name__ == "__main__":
220
 
221
  submit_btn.click(
222
  fn=lambda task, human_input, id: handle_create_sequential(task, human_input, session_manager, api_key, id),
223
- inputs=[description, human_input, identification_code],
224
  outputs=[ai_output, session_index]
225
  )
226
 
@@ -271,7 +276,7 @@ if __name__ == "__main__":
271
 
272
  create_initial_btn.click(
273
  fn=lambda task, id: handle_create_reverse_sequential(task, session_manager, api_key, id),
274
- inputs=[description, identification_code],
275
  outputs=[initial_answer, session_index]
276
  )
277
 
@@ -329,7 +334,7 @@ if __name__ == "__main__":
329
 
330
  create_btn.click(
331
  fn=lambda task, human_input, id: handle_create_parallel(task, human_input, session_manager, api_key, id),
332
- inputs=[description, human_input, identification_code],
333
  outputs=[ai_initial_output, session_index]
334
  )
335
 
 
3
  from save_data import add_or_update_row_at_fixed_position, get_sheet_service
4
  from instructions import *
5
  from user_groups import user_data
6
+ from constants import SDG_DETAILS, WORD_LIMIT_MIN, WORD_LIMIT_MAX, GROUP_SEPERATION, LOCAL_PARAMS
7
  from html_codes import *
8
 
9
  class SessionManager:
 
142
  words = human_input.split()
143
  if len(words) < WORD_LIMIT_MIN:
144
  return f"Error: Please enter at least 100 words."
145
+ elif len(words) > WORD_LIMIT_MAX:
146
+ return f"Error: Please enter less than 500 words."
147
  return None
148
 
149
  def on_textbox_change(session_index, session_manager, service, SHEET_ID):
 
178
  login_status = gr.Textbox(label="Next Tasks", interactive=False)
179
  group = gr.State()
180
 
181
+ with gr.Column(visible=False) as textbox_task:
182
  description = gr.Textbox(label="Task Description",
183
+ value = human_task_description(),
184
  interactive=False,
185
  lines=12)
186
 
187
  with gr.Accordion(label = "Click to See 17 SDGs",
188
  open=False):
189
  gr.Markdown(SDG_DETAILS)
190
+
191
+ ai_task_description = ai_task_description()
192
+
193
  # initialization of different group contents
194
  group_a_content = gr.Group(visible=False, elem_id="group-a")
195
  group_b_content = gr.Group(visible=False, elem_id="group-b")
 
208
  else:
209
  return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), invalid_group()
210
 
211
+ login_button.click(login, inputs=identification_code, outputs=[textbox_task, group_a_content, group_b_content, group_c_content, login_status])
212
 
213
 
214
 
 
225
 
226
  submit_btn.click(
227
  fn=lambda task, human_input, id: handle_create_sequential(task, human_input, session_manager, api_key, id),
228
+ inputs=[ai_task_description, human_input, identification_code],
229
  outputs=[ai_output, session_index]
230
  )
231
 
 
276
 
277
  create_initial_btn.click(
278
  fn=lambda task, id: handle_create_reverse_sequential(task, session_manager, api_key, id),
279
+ inputs=[ai_task_description, identification_code],
280
  outputs=[initial_answer, session_index]
281
  )
282
 
 
334
 
335
  create_btn.click(
336
  fn=lambda task, human_input, id: handle_create_parallel(task, human_input, session_manager, api_key, id),
337
+ inputs=[ai_task_description, human_input, identification_code],
338
  outputs=[ai_initial_output, session_index]
339
  )
340
 
constants.py CHANGED
@@ -1,4 +1,5 @@
1
  WORD_LIMIT_MIN = 100
 
2
  GROUP_SEPERATION = 1000
3
  LOCAL_PARAMS = False
4
 
 
1
  WORD_LIMIT_MIN = 100
2
+ WORD_LIMIT_MAX = 500
3
  GROUP_SEPERATION = 1000
4
  LOCAL_PARAMS = False
5
 
instructions.py CHANGED
@@ -57,8 +57,29 @@ def notes_for_participants():
57
 
58
  return NOTES
59
 
60
- def default_task_discription():
61
- TASK_DESCRIPTION = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  Given Airbnb's current business model below, please propose **three** ideas to make it comply with the 17 SDGs. Your output should be around **100** words in total.
63
 
64
  The final answer will be evaluated on Novelty (the uniqueness and originality of the ideas), Feasibility (the practicality and implementability of suggested actions), Inimitability (how difficult for competitors to replicate), and Goal Alignment (how aligned the ideas are with Airbnb’s business objectives and 17 SDGs).
@@ -94,4 +115,4 @@ def default_task_discription():
94
  16. Peace and Justice Strong Institutions: Promote peace, justice, and strong institutions.
95
  17. Partnerships to achieve the Goals: Enhance global partnerships for sustainable development.
96
  """
97
- return TASK_DESCRIPTION
 
57
 
58
  return NOTES
59
 
60
+ def human_task_description():
61
+ # display the task description on the interface to human
62
+ # TODO: Decorate the text to make it more readable
63
+ HUMAN_TASK_DESCRIPTION = """
64
+ Given Airbnb's current business model below, please propose three ideas to make it comply with the 17 SDGs.
65
+ The final answer should be at least 100 words.
66
+
67
+ Airbnb caters to two main groups:
68
+ 1. Travelers: People looking for unique and affordable places to stay, including tourists, business travelers, and families who prefer a home-like experience over hotels.
69
+ 2. Property Owners: Individuals who rent out their spaces, from single rooms to entire homes, to earn extra income.
70
+ Value for Guests and Hosts
71
+ - For Guests: Airbnb offers a variety of unique places to stay, providing a local and authentic experience with secure booking.
72
+ - For Hosts: Airbnb helps property owners make money by renting out their spaces and provides tools to list, price, and market their properties.
73
+ How Airbnb Operates
74
+ - User-Friendly Platform: Connects hosts with guests through an easy-to-use online marketplace.
75
+ - Safety and Support: Ensures safety with verification processes and offers reliable customer support.
76
+ - Technology and Marketing: Invests in technology to improve user experience and efficiency, and uses marketing to attract and retain users.
77
+ """
78
+ return HUMAN_TASK_DESCRIPTION
79
+
80
+ def ai_task_description():
81
+ # task description passed to AI in the prompt
82
+ AI_TASK_DESCRIPTION = """
83
  Given Airbnb's current business model below, please propose **three** ideas to make it comply with the 17 SDGs. Your output should be around **100** words in total.
84
 
85
  The final answer will be evaluated on Novelty (the uniqueness and originality of the ideas), Feasibility (the practicality and implementability of suggested actions), Inimitability (how difficult for competitors to replicate), and Goal Alignment (how aligned the ideas are with Airbnb’s business objectives and 17 SDGs).
 
115
  16. Peace and Justice Strong Institutions: Promote peace, justice, and strong institutions.
116
  17. Partnerships to achieve the Goals: Enhance global partnerships for sustainable development.
117
  """
118
+ return AI_TASK_DESCRIPTION
utils.py CHANGED
@@ -34,7 +34,6 @@ def generate_text_with_gpt(prompts, api_key = None):
34
  """Generate text using the GPT-4o model."""
35
  if api_key:
36
  openai.api_key = api_key
37
-
38
  try:
39
  response = openai.ChatCompletion.create(
40
  model="gpt-4o",
 
34
  """Generate text using the GPT-4o model."""
35
  if api_key:
36
  openai.api_key = api_key
 
37
  try:
38
  response = openai.ChatCompletion.create(
39
  model="gpt-4o",