agentsociety.survey.manager

Module Contents

Classes

API

class agentsociety.survey.manager.SurveyManager

Initialization

Initializes a new instance of the SurveyManager class.

  • Description:

    • Manages the creation and retrieval of surveys. Uses an internal dictionary to store survey instances by their unique identifier.

  • Attributes:

    • _surveys (dict[str, Survey]): A dictionary mapping survey IDs to Survey instances.

create_survey(title: str, description: str, pages: list[dict]) → agentsociety.survey.models.Survey

Create a new survey with specified title, description, and pages containing questions.

  • Description:

    • Generates a unique ID for the survey, converts the provided page and question data into Page and Question objects, and adds the created survey to the internal storage.

  • Args:

    • title (str): The title of the survey.

    • description (str): A brief description of what the survey is about.

    • pages (list[dict]): A list of dictionaries where each dictionary contains page information including elements which are question definitions.

  • Returns:

    • Survey: An instance of the Survey class representing the newly created survey.

get_survey(survey_id: str) → Optional[agentsociety.survey.models.Survey]

Retrieve a specific survey by its unique identifier.

  • Description:

    • Searches for a survey within the internal storage using the provided survey ID.

  • Args:

    • survey_id (str): The unique identifier of the survey to retrieve.

  • Returns:

    • Optional[Survey]: An instance of the Survey class if found; otherwise, None.

get_all_surveys() → list[agentsociety.survey.models.Survey]

Get all surveys that have been created.

  • Description:

    • Retrieves all stored surveys from the internal storage.

  • Returns:

    • list[Survey]: A list of Survey instances.