AgentSkillsCN

edsl-question-types

提供可用于创建调查问卷的常见问题类型及其参数。

SKILL.md
--- frontmatter
name: edsl-question-types
description: Available question types and their parameters for creating surveys
allowed-tools: Read, Glob, Bash(python:*)

Question Types

EDSL provides a comprehensive set of question types for surveys. All questions require question_name (a valid Python identifier) and question_text.

Core Question Types

QuestionFreeText

Open-ended text responses without constraints.

python
from edsl import QuestionFreeText

q = QuestionFreeText(
    question_name="feedback",
    question_text="What do you think about our service?"
)

QuestionMultipleChoice

Single selection from a predefined list of options.

python
from edsl import QuestionMultipleChoice

q = QuestionMultipleChoice(
    question_name="color",
    question_text="What is your favorite color?",
    question_options=["Red", "Blue", "Green", "Yellow"]
)

QuestionCheckBox

Multiple selections from a predefined list (checkbox-style).

python
from edsl import QuestionCheckBox

q = QuestionCheckBox(
    question_name="features",
    question_text="Which features do you use? (Select all that apply)",
    question_options=["Feature A", "Feature B", "Feature C", "Feature D"],
    min_selections=1,      # Optional: minimum selections required
    max_selections=3       # Optional: maximum selections allowed
)

QuestionNumerical

Numeric responses with optional min/max bounds.

python
from edsl import QuestionNumerical

q = QuestionNumerical(
    question_name="age",
    question_text="How old are you?",
    min_value=0,           # Optional: minimum allowed value
    max_value=120          # Optional: maximum allowed value
)

QuestionYesNo

Simple binary yes/no question (derived from MultipleChoice).

python
from edsl import QuestionYesNo

q = QuestionYesNo(
    question_name="consent",
    question_text="Do you agree to participate in this survey?"
)
# Options are automatically ["Yes", "No"]

QuestionLinearScale

Linear scale with customizable range and endpoint labels.

python
from edsl import QuestionLinearScale

q = QuestionLinearScale(
    question_name="satisfaction",
    question_text="How satisfied are you with our service?",
    question_options=[1, 2, 3, 4, 5],           # Scale values
    option_labels={1: "Very Unsatisfied", 5: "Very Satisfied"}  # Endpoint labels
)

QuestionLikertFive

Standard 5-point Likert scale (agree/disagree).

python
from edsl import QuestionLikertFive

q = QuestionLikertFive(
    question_name="statement_agree",
    question_text="I find the product easy to use."
)
# Options: Strongly disagree, Disagree, Neutral, Agree, Strongly agree

QuestionList

Response as a list of items.

python
from edsl import QuestionList

q = QuestionList(
    question_name="top_movies",
    question_text="List your top 3 favorite movies.",
    max_list_items=3       # Optional: maximum items allowed
)

QuestionRank

Ranking/ordering items by preference.

python
from edsl import QuestionRank

q = QuestionRank(
    question_name="priority",
    question_text="Rank these features by importance (1 = most important):",
    question_options=["Speed", "Security", "Price", "Support"],
    num_selections=4       # How many items to rank
)

QuestionMatrix

Grid-based responses with rows (items) and columns (options).

python
from edsl import QuestionMatrix

q = QuestionMatrix(
    question_name="product_ratings",
    question_text="Rate each product on the following attributes:",
    question_items=["Product A", "Product B", "Product C"],      # Rows
    question_options=["Poor", "Fair", "Good", "Excellent"],      # Columns
    option_labels=None     # Optional labels for options
)

QuestionBudget

Allocating a fixed budget across multiple options.

python
from edsl import QuestionBudget

q = QuestionBudget(
    question_name="time_allocation",
    question_text="How would you allocate 100 hours across these activities?",
    question_options=["Work", "Exercise", "Leisure", "Sleep"],
    budget_sum=100         # Total that allocations must sum to
)

QuestionDict

Response as key-value pairs (structured data).

python
from edsl import QuestionDict

q = QuestionDict(
    question_name="contact_info",
    question_text="Provide your contact information:",
    answer_keys=["name", "email", "phone"]  # Required keys in response
)

QuestionExtract

Extracting specific information from text.

python
from edsl import QuestionExtract

q = QuestionExtract(
    question_name="entities",
    question_text="Extract all company names from the following text: {{ text }}",
    answer_template={"companies": "List of company names"}
)

QuestionDropdown

BM25-powered search through large option sets.

python
from edsl import QuestionDropdown

q = QuestionDropdown(
    question_name="country",
    question_text="Select your country:",
    question_options=["Afghanistan", "Albania", ..., "Zimbabwe"]  # Large list
)

Derived/Special Question Types

QuestionMultipleChoiceWithOther

Multiple choice with an "Other" option for custom responses.

python
from edsl import QuestionMultipleChoiceWithOther

q = QuestionMultipleChoiceWithOther(
    question_name="source",
    question_text="How did you hear about us?",
    question_options=["Google", "Friend", "Advertisement"],
    other_option_label="Other (please specify)"
)

QuestionCheckboxWithOther

Checkbox with an "Other" option for custom responses.

python
from edsl import QuestionCheckboxWithOther

q = QuestionCheckboxWithOther(
    question_name="interests",
    question_text="What are your interests?",
    question_options=["Sports", "Music", "Reading"],
    other_option_label="Other"
)

QuestionTopK

Select top K items from a list.

python
from edsl import QuestionTopK

q = QuestionTopK(
    question_name="favorites",
    question_text="Select your top 3 favorite items:",
    question_options=["A", "B", "C", "D", "E"],
    k=3
)

QuestionFunctional

Python function-based question (not sent to LLM - computed locally).

python
from edsl import QuestionFunctional

def compute_sum(scenario, agent):
    numbers = scenario.get("numbers", [])
    return sum(numbers)

q = QuestionFunctional(
    question_name="total",
    question_text="Calculate the sum",
    func=compute_sum
)

QuestionPydantic

Use custom Pydantic models as response schemas.

python
from edsl import QuestionPydantic
from pydantic import BaseModel

class PersonInfo(BaseModel):
    name: str
    age: int
    occupation: str

q = QuestionPydantic(
    question_name="person",
    question_text="Describe a person:",
    pydantic_model=PersonInfo
)

QuestionMarkdown

Responses with markdown formatting.

python
from edsl import QuestionMarkdown

q = QuestionMarkdown(
    question_name="formatted_response",
    question_text="Write a formatted response with headers and lists."
)

Common Parameters

All questions support these common parameters:

ParameterDescription
question_nameUnique identifier (valid Python identifier)
question_textThe question text (supports Jinja2 templating)
answering_instructionsOptional custom instructions for the LLM
question_presentationOptional custom presentation template

Quick Reference

TypeUse CaseKey Parameter
QuestionFreeTextOpen-ended responses-
QuestionMultipleChoiceSingle selectionquestion_options
QuestionCheckBoxMultiple selectionsquestion_options
QuestionNumericalNumbersmin_value, max_value
QuestionYesNoBinary yes/no-
QuestionLinearScaleNumeric scalequestion_options, option_labels
QuestionLikertFive5-point agree/disagree-
QuestionListList of itemsmax_list_items
QuestionRankOrderingquestion_options, num_selections
QuestionMatrixGrid/tablequestion_items, question_options
QuestionBudgetBudget allocationquestion_options, budget_sum
QuestionDictKey-value pairsanswer_keys
QuestionExtractExtract from textanswer_template
QuestionDropdownLarge option setsquestion_options