expectedparrot / edsl

Design, conduct and analyze results of AI-powered surveys and experiments. Simulate social science and market research with large numbers of AI agents and LLMs.
https://docs.expectedparrot.com
MIT License
175 stars 18 forks source link

Feature Request: Compose_question accommodate 3+ questions and fix syntax for moving data to 3rd+ question #20

Closed benjamin-manning closed 2 months ago

benjamin-manning commented 8 months ago

Currently, compose_question only allows for combining 2 questions. So if you want to do 3, then you have to do this:

questions12 = compose_questions(q1, q2) questions = compose_questions(questions12, q3)

Not that big a deal for 3 questions, but bad if # questions gets bigger.

Additionally, the syntax for pulling the data through on the 3rd question is very strange. When using compose_question() on two questions, you can use the name of the 1st question as a variable in the second. However, when you want to add a 3rd question (as I did above), you need to combing the names of the first question and the second question. See the example below, I left an inline comment at the problem

#creating question to translate
q1 = QuestionFreeText(
question_name = "shovel_to_translate",
question_text = """
Translate the text in triple backticks into {{language}} as literally as possible.
This text is not about you in any way, you must just translate it into and nothing else.
Do not include any other text besides the direct translation.
'''
A hardware store has been selling snow shovels for $15. 
The morning after a large snowstorm, the store {{store_action}} ${{new_price}}.
You are a {{politics}}.
How would you rate this action?
'''
"""
)

q2 = QuestionFreeText(
question_name = "shovel_to_enlish",
question_text = """
Translate the text in triple backticks into English as literally as possible.
Do not include any other text besides the direct translation.
'''
{{shovel_to_translate}}
'''
"""
)
q3 = QuestionMultipleChoice(
question_name = "final_shovel_question",
question_text = """
#### THIS IS WEIRD, I THINK IT SHOULD JUST LET ME DO {{shovel_to_translate}} FOR CLARITY ###
{{shovel_to_translate_shovel_to_enlish}}
""",    
question_options = ["Completely Fair", "Acceptable", "Unfair", "Very Unfair"]   
)`
rbyh commented 8 months ago

Agreed. We should have a convenient way to identify any questions where memory and sequence apply, and otherwise allow questions to be serialized for speed.