gabm.abm.survey module
Survey module for GABM.
- class gabm.abm.survey.Answer(answer_id: AnswerID, text: str)
Bases:
objectRepresents a single answer to a question.
- Attributes:
id (AnswerID): The id of the Answer text (str): The answer text. answers (List[Answer]): List of available Answers.
- class gabm.abm.survey.AnswerID(answer_id: int)
Bases:
GABMIDA unique identifier for a Answer instance.
- Attributes:
id (int): The unique identifier for the answer.
- class gabm.abm.survey.Question(question_id: QuestionID, text: str, answers: List[Answer] = None)
Bases:
objectRepresents a single survey question.
- Attributes:
id (QuestionID): The question identifier. text (str): The question text. answers (List[Answer]): List of available Answers.
- get_prompt() str
Get the LLM prompt for the question - the text and available answers.
- Returns:
A string representation of the question context.
- class gabm.abm.survey.QuestionID(question_id: int)
Bases:
GABMIDA unique identifier for a Question instance.
- Attributes:
id (int): The unique identifier for the question.
- class gabm.abm.survey.Survey(questions: List[Question], title: str = '', description: str = '')
Bases:
objectRepresents a survey comprising multiple questions.
- Attributes:
questions (List[Question]): The list of questions in the survey. title (str): The title of the survey. description (str): Description of the survey.
- class gabm.abm.survey.SurveyConversation(person: Person, survey: Survey, llm_service: LLMService, api_key: str = None, model: str = None)
Bases:
objectHandles a conversation between a Person (with a Profile/Persona) and an LLM for survey response simulation.
- Attributes:
person (Person): The person instance. survey (Survey): The survey to be conducted. llm_service (LLMService): The LLM service interface (to be implemented). api_key (str): The API key for the LLM service. model (str): The model to use for the LLM service. responses (List[str]): The list of responses from the LLM for each question.
- conduct()
Conducts the survey by asking each question to the LLM with the given profile context. Stores responses in self.responses.