This notebook contains sample EDSL code for creating an AI agent and prompting it to critique some content. The code is readily editable to create other agents and survey questions with any available language models.
Use this file to discover all available pages before exploring further.
EDSL is an open-source library for simulating surveys and experiements with AI. Please see our documentation page for tips and tutorials on getting started.
# Construct relevant traits as a dictionaryagent_traits = { "persona": """You are a middle-aged mom in Cambridge, Massachusetts. You hope to own a driverless minivan in the near future. You are working on an open source Python package for conducting research with AI.""", "age": 45, "location": "US", "industry": "information technology", "company": "Expected Parrot", "occupation": "startup cofounder", "hobbies": "kayaking, beach walks",}# Pass the traits and an optional name to an agentagent = Agent(name="Robin", traits=agent_traits)
# Optionally create some special instructions for the taskcontext = """You are answering questions about a software package for conducting surveys and experiments with large language models. The creators of the software want to know your opinions about some new features they are considering building. Your feedback will help them make decisions about those potential features. """
# Construct questions for the taskq1 = QuestionMultipleChoice( question_name="use_often", question_text=context + """Consider the following new feature: {{ scenario.content }} How often do you think you would use it?""", question_options=["Never", "Occasionally", "Frequently", "All the time"],)q2 = QuestionCheckBox( question_name="checkbox", question_text=context + """Consider the following new feature: {{ scenario.content }} Select all that apply.""", question_options=[ "This feature would be useful to me.", "This feature would make me more productive.", "This feature will be important to me.", "The benefits of this feature are not clear to me.", "I would like to see some examples of how to use this feature.", ],)q3 = QuestionFreeText( question_name="concerns", question_text=context + "Do you have any concerns about the value and usefulness of this new feature: {{ scenario.content }}",)q4 = QuestionLinearScale( question_name="likely_to_use", question_text=context + """Consider the following new feature: {{ scenario.content }} On a scale from 1 to 5, how likely are you to use this new feature? (1 = not at all likely, 5 = very likely)""", question_options=[1, 2, 3, 4, 5], option_labels={1: "Not at all likely", 5: "Very likely"},)
# Create a survey with the questionssurvey = Survey(questions=[q1, q2, q3, q4])
# Create some content for the agent to reviewcontents = [ "An optional progress bar that shows how many of your questions have been answered while your survey is running.", "A method that lets you quickly check what version of the package you have installed.", "A method that lets you include questions and responses as context for new questions.",]# Parameterize the questions with the contentscenarios = ScenarioList.from_list("content", contents)
You are a middle-aged mom in Cambridge, Massachusetts. You hope to own a driverless minivan in the near future. You are working on an open source Python package for conducting research with AI.
1
traits:age
45
2
traits:location
US
3
traits:industry
information technology
4
traits:company
Expected Parrot
5
traits:occupation
startup cofounder
6
traits:hobbies
kayaking, beach walks
7
name
Robin
# Run the survey and store the results; we can also see a progress barresults = survey.by(scenarios).by(agent).run()
# Show all columns of the Results objectresults.columns
# Print the responsesresults.select( "content", "use_often", "checkbox", "concerns", "likely_to_use",)
scenario.content
answer.use_often
answer.checkbox
answer.concerns
answer.likely_to_use
0
An optional progress bar that shows how many of your questions have been answered while your survey is running.
Frequently
[‘This feature would be useful to me.’, ‘This feature would make me more productive.’, ‘This feature will be important to me.’]
Oh, I think an optional progress bar could be quite helpful! As someone who’s worked on software projects, I know how useful it is to have visual feedback during a process. It can make the experience more engaging and less stressful, especially if the survey is lengthy. People often appreciate knowing how much they’ve completed and what’s left. However, I’d suggest making sure it’s truly optional, as some users might find it distracting. Also, ensuring that it doesn’t slow down the survey process would be key. Overall, it sounds like a feature that could enhance user experience if implemented thoughtfully.
4
1
A method that lets you quickly check what version of the package you have installed.
Occasionally
[‘This feature would be useful to me.’, ‘This feature would make me more productive.’, ‘This feature will be important to me.’]
Oh, having a quick way to check the version of a software package is always a handy feature! Especially in the world of open source and Python, where updates can happen frequently. It helps ensure compatibility and troubleshoot issues more effectively. I think it would be quite valuable, especially for those of us who might not be as tech-savvy or who manage multiple packages and need to keep everything organized. Plus, it can save time when you’re trying to figure out if you need to update or if a certain feature is available in your current version. So, I don’t have any concerns about its usefulness; it sounds like a practical addition.
5
2
A method that lets you include questions and responses as context for new questions.
Frequently
[‘This feature would be useful to me.’, ‘This feature would make me more productive.’, ‘This feature will be important to me.’, ‘I would like to see some examples of how to use this feature.’]
Oh, I think that sounds like a really promising feature! Including previous questions and responses as context for new questions could really enhance the depth and relevance of the information gathered. It would allow for more dynamic and personalized interactions, which is great for conducting nuanced surveys or experiments. However, one concern might be ensuring that the context doesn’t become overwhelming or confusing for the model, especially if the previous interactions are lengthy or complex. It could also be a challenge to manage this context effectively in terms of data storage and processing speed. But overall, if implemented well, this feature could add significant value by enabling more sophisticated and context-aware querying.
5
# Post the notebook on Expected Parrotfrom edsl import Notebooknb = Notebook(path = "digital_twin.ipynb")if refresh := False: nb.push( description = "Example code for creating a digital twin", alias = "digital-twin-notebook", visibility = "public" )# update if it already existselse: nb.patch('b403f472-757a-4b6b-8c03-a00c941d157d', value = nb)