A Python-based survey system that conducts automated intellectual preference surveys using LLM-powered question selection. The system intelligently selects questions based on previous responses, creating a personalized and coherent survey experience.
This project implements an automated survey system that:
- Conducts surveys using a curated bank of 31 philosophical/theological questions
- Uses Google's Gemini 2.0 Flash model (via OpenRouter API) to intelligently select questions
- Limits each survey to 5 questions, ensuring focused and efficient data collection
- Prevents question repetition within each survey session
- Simulates user responses (yes/no) for testing purposes
- Saves survey results with timestamps in JSON format
- Dynamic Question Selection: Uses LLM to choose the most contextually appropriate next question based on previous responses
- State Management: Tracks conversation history and remaining questions to prevent duplicates
- Persistent Storage: Saves all survey results in a structured JSON format
- Multiple Survey Support: Can run multiple survey sessions in sequence
- API Error Handling: Robust error handling for API interactions
- Configurable: Supports custom API keys and save locations
- Python 3.7+
- OpenRouter API key
- Required Python packages (see
requirements.txt)
- Clone the repository:
git clone https://github.com/philipgalebach/intellectual-preference-survey.git
cd intellectual-preference-survey- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the project root with your OpenRouter API key:
OPENROUTER_API_KEY=your_api_key_here
Run a single survey:
python survey.pyRun multiple surveys:
python survey.py 5 # Runs 5 survey sessionsSurvey results are saved in simulations/survey_results.json with the following structure:
[
{
"timestamp": "20250220_234416",
"responses": [
{
"question": "Is doubt part of authentic faith?",
"answer": "yes"
},
// ... more responses
]
}
]intellectual-preference-survey/
├── survey.py # Main survey implementation
├── requirements.txt # Python dependencies
├── .env # API key configuration
├── simulations/ # Survey results directory
│ └── survey_results.json
└── README.md # This file
The survey system can be configured through:
-
Environment variables in
.env:OPENROUTER_API_KEY: Your OpenRouter API key
-
Command line arguments:
- First argument: Number of survey runs (default: 1)