edsl
edsl copied to clipboard
Create prompts that can use QuestionFreeText (or other question types) to return a dictionary
It can be useful to have the agent return a dictionary (eg agent traits) but this is not addressed with existing question type prompts. Eg trying to manipulate QuestionFreeText to do this throws an error because the response is not a string:
q_ranges = QuestionFreeText(
question_name = "ranges",
question_text = """You are being asked to design a survey about job posts at Upwork.
Provide a dictionary where the keys are dimensions of freelancers
and the values are lists of possible options for those dimensions."""
)
q_ranges.by(model).run().select("ranges").print()
Using QuestionList to return a list of dicts is workable option:
"Return the dict as a single item in a list" is hacky use of QuestionList that works:
Another approach is to do something like this where you break in into steps:
https://embed.deepnote.com/dceaad48-76c8-4ecb-a682-3eea29a1bfb2/3ca7ff714cdb4e978b93345638d23d2c/7d72edc51bff40edab51344cf0c6ad24?height=1797.0999755859375