Spaces:
Sleeping
Sleeping
Merge pull request #1 from ZnS77/feature/prompt-update
Browse files- app.py +4 -4
- constants.py +1 -1
- instructions.py +25 -2
- utils.py +5 -5
app.py
CHANGED
|
@@ -141,7 +141,7 @@ def login(identification_code):
|
|
| 141 |
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
|
| 145 |
return None
|
| 146 |
|
| 147 |
def on_textbox_change(session_index, session_manager, service, SHEET_ID):
|
|
@@ -209,7 +209,7 @@ if __name__ == "__main__":
|
|
| 209 |
|
| 210 |
with group_a_content:
|
| 211 |
with gr.Row():
|
| 212 |
-
human_input = gr.Textbox(label="Enter each idea on a new line, starting with '1', '2', and '3'
|
| 213 |
word_count_display_a = gr.Label(value="Word count: 0")
|
| 214 |
human_input.change(fn=update_word_count, inputs=human_input, outputs=word_count_display_a)
|
| 215 |
with gr.Row():
|
|
@@ -257,7 +257,7 @@ if __name__ == "__main__":
|
|
| 257 |
with gr.Row():
|
| 258 |
initial_answer = gr.Textbox(label="AI Output", interactive=False)
|
| 259 |
with gr.Row():
|
| 260 |
-
modification_suggestions = gr.Textbox(label="
|
| 261 |
word_count_display_b = gr.Label(value="Word count: 0")
|
| 262 |
modification_suggestions.change(fn=update_word_count, inputs=modification_suggestions, outputs=word_count_display_b)
|
| 263 |
modification_suggestions.change(fn=check_initial_generated, inputs = [initial_answer] )
|
|
@@ -313,7 +313,7 @@ if __name__ == "__main__":
|
|
| 313 |
|
| 314 |
with group_c_content:
|
| 315 |
with gr.Row():
|
| 316 |
-
human_input = gr.Textbox(label="Enter each idea on a new line, starting with '1', '2', and '3'
|
| 317 |
word_count_display_c = gr.Label(value="Word count: 0")
|
| 318 |
human_input.change(fn=update_word_count, inputs=human_input, outputs=word_count_display_c)
|
| 319 |
with gr.Row():
|
|
|
|
| 141 |
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):
|
|
|
|
| 209 |
|
| 210 |
with group_a_content:
|
| 211 |
with gr.Row():
|
| 212 |
+
human_input = gr.Textbox(label="Enter each idea on a new line (Shift+Enter), starting with '1', '2', and '3'.", placeholder="Please propose 3 ideas to help Airbnb’s business model align with 17 SDGs (At least 100 words)")
|
| 213 |
word_count_display_a = gr.Label(value="Word count: 0")
|
| 214 |
human_input.change(fn=update_word_count, inputs=human_input, outputs=word_count_display_a)
|
| 215 |
with gr.Row():
|
|
|
|
| 257 |
with gr.Row():
|
| 258 |
initial_answer = gr.Textbox(label="AI Output", interactive=False)
|
| 259 |
with gr.Row():
|
| 260 |
+
modification_suggestions = gr.Textbox(label="Please refine AI's three ideas as your final answer, starting with '1', '2', and '3'.", placeholder="Please propose 3 ideas to help Airbnb’s business model align with 17 SDGs (At least 100 words)")
|
| 261 |
word_count_display_b = gr.Label(value="Word count: 0")
|
| 262 |
modification_suggestions.change(fn=update_word_count, inputs=modification_suggestions, outputs=word_count_display_b)
|
| 263 |
modification_suggestions.change(fn=check_initial_generated, inputs = [initial_answer] )
|
|
|
|
| 313 |
|
| 314 |
with group_c_content:
|
| 315 |
with gr.Row():
|
| 316 |
+
human_input = gr.Textbox(label="Enter each idea on a new line (Shift+Enter), starting with '1', '2', and '3'.", placeholder="Please propose 3 ideas to help Airbnb’s business model align with 17 SDGs (At least 100 words)")
|
| 317 |
word_count_display_c = gr.Label(value="Word count: 0")
|
| 318 |
human_input.change(fn=update_word_count, inputs=human_input, outputs=word_count_display_c)
|
| 319 |
with gr.Row():
|
constants.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
WORD_LIMIT_MIN =
|
| 2 |
GROUP_SEPERATION = 1000
|
| 3 |
LOCAL_PARAMS = False
|
| 4 |
|
|
|
|
| 1 |
+
WORD_LIMIT_MIN = 100
|
| 2 |
GROUP_SEPERATION = 1000
|
| 3 |
LOCAL_PARAMS = False
|
| 4 |
|
instructions.py
CHANGED
|
@@ -51,7 +51,7 @@ def invalid_group():
|
|
| 51 |
|
| 52 |
def notes_for_participants():
|
| 53 |
NOTES = """
|
| 54 |
-
You will receive basic compensation 💰 for a valid response of at least
|
| 55 |
Your final answer will be evaluated. If it ranks in the top 30 of 600 participants, you’ll earn an extra 🎁 $15.
|
| 56 |
"""
|
| 57 |
|
|
@@ -59,7 +59,10 @@ def notes_for_participants():
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
| 63 |
Airbnb caters to two main groups:
|
| 64 |
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.
|
| 65 |
2. Property Owners: Individuals who rent out their spaces, from single rooms to entire homes, to earn extra income.
|
|
@@ -70,5 +73,25 @@ def default_task_discription():
|
|
| 70 |
- User-Friendly Platform: Connects hosts with guests through an easy-to-use online marketplace.
|
| 71 |
- Safety and Support: Ensures safety with verification processes and offers reliable customer support.
|
| 72 |
- Technology and Marketing: Invests in technology to improve user experience and efficiency, and uses marketing to attract and retain users.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
"""
|
| 74 |
return TASK_DESCRIPTION
|
|
|
|
| 51 |
|
| 52 |
def notes_for_participants():
|
| 53 |
NOTES = """
|
| 54 |
+
You will receive basic compensation 💰 for a valid response of at least 100 words.
|
| 55 |
Your final answer will be evaluated. If it ranks in the top 30 of 600 participants, you’ll earn an extra 🎁 $15.
|
| 56 |
"""
|
| 57 |
|
|
|
|
| 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).
|
| 65 |
+
|
| 66 |
Airbnb caters to two main groups:
|
| 67 |
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.
|
| 68 |
2. Property Owners: Individuals who rent out their spaces, from single rooms to entire homes, to earn extra income.
|
|
|
|
| 73 |
- User-Friendly Platform: Connects hosts with guests through an easy-to-use online marketplace.
|
| 74 |
- Safety and Support: Ensures safety with verification processes and offers reliable customer support.
|
| 75 |
- Technology and Marketing: Invests in technology to improve user experience and efficiency, and uses marketing to attract and retain users.
|
| 76 |
+
|
| 77 |
+
17 Sustainable Development Goals (SDGs):
|
| 78 |
+
|
| 79 |
+
1. No Poverty: Eradicate all forms of poverty.
|
| 80 |
+
2. Zero Hunger: End hunger and promote sustainable agriculture.
|
| 81 |
+
3. Good Health and Well-being: Ensure health and well-being for everyone.
|
| 82 |
+
4. Quality Education: Guarantee inclusive, quality education for all.
|
| 83 |
+
5. Gender Equality: Empower women and achieve gender equality.
|
| 84 |
+
6. Clean Water and Sanitation: Provide sustainable water and sanitation.
|
| 85 |
+
7. Affordable and Clean Energy: Ensure access to sustainable energy.
|
| 86 |
+
8. Decent Work and Economic Growth: Foster inclusive economic growth and decent jobs.
|
| 87 |
+
9. Industry, Innovation and Infrastructure: Build resilient infrastructure and promote innovation.
|
| 88 |
+
10. Reduced Inequality: Decrease inequality within and among countries.
|
| 89 |
+
11. Sustainable Cities and Communities: Develop safe and sustainable communities.
|
| 90 |
+
12. Responsible Consumption and Production: Ensure sustainable consumption and production.
|
| 91 |
+
13. Climate Action: Take action against climate change.
|
| 92 |
+
14. Life Below Water: Protect oceans and marine life.
|
| 93 |
+
15. Life on Land: Sustainably manage ecosystems and biodiversity.
|
| 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
|
utils.py
CHANGED
|
@@ -56,20 +56,20 @@ def generate_ai_initial_answer(task_description, api_key=None):
|
|
| 56 |
def merge_texts_parallel(task_description, human_text, ai_text, api_key = None):
|
| 57 |
prompt = (
|
| 58 |
"You are tasked with merging two answers into a single, coherent, and logically structured response. "
|
| 59 |
-
"Your response should synthesize the strengths of both answers, eliminate redundancy, and ensure a logical flow.
|
| 60 |
"Follow this structured chain of thought to guide your process:\n\n"
|
| 61 |
"1. Understand the Task: Start by carefully analyzing the task description to ensure your final response aligns fully with the objective.\n"
|
| 62 |
"2. Extract Key Points: Review both answers and identify the key ideas and arguments they present.\n"
|
| 63 |
"3. Resolve Redundancies and Conflicts: Compare the two answers to eliminate repetitive content and resolve any contradictions.\n"
|
| 64 |
"4. Integrate Seamlessly: Combine the extracted points into a single, unified response, ensuring a logical and coherent structure.\n"
|
| 65 |
-
"5. Refine for Clarity: Polish the final response for clarity, conciseness, and alignment with the task
|
| 66 |
"Task Description:\n"
|
| 67 |
f"{task_description}\n\n"
|
| 68 |
"Answer 1:\n"
|
| 69 |
f"{human_text}\n\n"
|
| 70 |
"Answer 2:\n"
|
| 71 |
f"{ai_text}\n\n"
|
| 72 |
-
"Provide the
|
| 73 |
)
|
| 74 |
return generate_text_with_gpt(prompt, api_key)
|
| 75 |
|
|
@@ -77,14 +77,14 @@ def merge_texts_sequential(task_description, human_text, api_key = None):
|
|
| 77 |
prompt = (
|
| 78 |
f"Given the task: {task_description}, here is the response provided by the human:\n"
|
| 79 |
f"{human_text}\n\n"
|
| 80 |
-
"Your task is to refine the human's response while ensuring that the final answer fully aligns with
|
| 81 |
"Follow this logical chain of thought:\n"
|
| 82 |
"1. Understand the Intent: Analyze the human's response to identify their key points and intended message.\n"
|
| 83 |
"2. Evaluate Clarity: Check for any ambiguities, gaps, or unclear phrasing in the response.\n"
|
| 84 |
"3. Improve Coherence: Ensure the response flows logically and connects ideas seamlessly.\n"
|
| 85 |
"4. Enhance Precision: Refine wording to be concise and impactful while preserving the human's original intent.\n"
|
| 86 |
"5. Check Alignment: Confirm that the final response accurately represents and strengthens the human's input without introducing unintended changes.\n\n"
|
| 87 |
-
"Provide the refined response below
|
| 88 |
)
|
| 89 |
|
| 90 |
return generate_text_with_gpt(prompt, api_key)
|
|
|
|
| 56 |
def merge_texts_parallel(task_description, human_text, ai_text, api_key = None):
|
| 57 |
prompt = (
|
| 58 |
"You are tasked with merging two answers into a single, coherent, and logically structured response. "
|
| 59 |
+
"Your response should synthesize the strengths of both answers, eliminate redundancy, and ensure a logical flow."
|
| 60 |
"Follow this structured chain of thought to guide your process:\n\n"
|
| 61 |
"1. Understand the Task: Start by carefully analyzing the task description to ensure your final response aligns fully with the objective.\n"
|
| 62 |
"2. Extract Key Points: Review both answers and identify the key ideas and arguments they present.\n"
|
| 63 |
"3. Resolve Redundancies and Conflicts: Compare the two answers to eliminate repetitive content and resolve any contradictions.\n"
|
| 64 |
"4. Integrate Seamlessly: Combine the extracted points into a single, unified response, ensuring a logical and coherent structure.\n"
|
| 65 |
+
"5. Refine for Clarity: Polish the final response for clarity, conciseness, and alignment with the task description below.\n\n"
|
| 66 |
"Task Description:\n"
|
| 67 |
f"{task_description}\n\n"
|
| 68 |
"Answer 1:\n"
|
| 69 |
f"{human_text}\n\n"
|
| 70 |
"Answer 2:\n"
|
| 71 |
f"{ai_text}\n\n"
|
| 72 |
+
"Provide the merged response below."
|
| 73 |
)
|
| 74 |
return generate_text_with_gpt(prompt, api_key)
|
| 75 |
|
|
|
|
| 77 |
prompt = (
|
| 78 |
f"Given the task: {task_description}, here is the response provided by the human:\n"
|
| 79 |
f"{human_text}\n\n"
|
| 80 |
+
"Your task is to refine the human's response while ensuring that the final answer fully aligns with the objectives for this task."
|
| 81 |
"Follow this logical chain of thought:\n"
|
| 82 |
"1. Understand the Intent: Analyze the human's response to identify their key points and intended message.\n"
|
| 83 |
"2. Evaluate Clarity: Check for any ambiguities, gaps, or unclear phrasing in the response.\n"
|
| 84 |
"3. Improve Coherence: Ensure the response flows logically and connects ideas seamlessly.\n"
|
| 85 |
"4. Enhance Precision: Refine wording to be concise and impactful while preserving the human's original intent.\n"
|
| 86 |
"5. Check Alignment: Confirm that the final response accurately represents and strengthens the human's input without introducing unintended changes.\n\n"
|
| 87 |
+
"Provide the refined response below."
|
| 88 |
)
|
| 89 |
|
| 90 |
return generate_text_with_gpt(prompt, api_key)
|