π§ AI Agents - Quiz Maker with OpenAI Agent SDK
Recently OpenAI has released their Agent SDK, so i decided to explor its potential to build something practical for education/learning porpouse.
This led me to create an automated pipeline that turns educational content into structured quizzes. The system accepts either PDF files or web URLs, processes them using agents, and outputs multiple-choice questions with a structured scoring system.
The goal? Support learning by extracting meaningful concepts and transforming them into a gamified quiz experience.
For this project, I built an agentic system with:
- Text extraction via
PyPDFLoader
andWebBaseLoader
- Concept summarization in the choosen language
- Agent-generated quizzes with scoring
- A Streamlit-based UI for user-friendly interaction
ποΈ Architecture
Below is an overview of the architecture of the agentic pipeline that powers the Quiz Maker:
Step 1: Provide Input
The user uploads one or more PDF documents or pastes a list of web URLs.
Step 2: Text Extraction
Content is extracted using:
- PyPDFLoader (for PDFs)
- WebBaseLoader + Html2TextTransformer (for web content)
Step 3: Summarization
A text summarizer agent analyzes the extracted content and organizes the main concepts to serve as the knowledge base for quiz generation.
Step 4: Quiz Generation
A quiz generator agent creates 10 multiple-choice questions, each with:
- One correct answer (5 points)
- One partially correct answer (2 points)
- One incorrect answer (0 points)
- One misleading/harmful answer (-2 points)
Step 5: Save Results
- Summarized content and raw text are saved in dedicated folders
- The final quizzes are saved in structured JSON format
π‘ JSON Output Format
Each quiz is saved with this structure:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"questions": [
{
"theme": "question theme",
"question_text": "Question text?",
"answers": [
{ "text": "Correct answer", "score": 5 },
{ "text": "Partially correct answer", "score": 2 },
{ "text": "Incorrect answer", "score": 0 },
{ "text": "Misleading answer", "score": -2 }
]
}
]
}
πΊ Quiz Maker UI
Here are some screenshots of the Streamlit interface:
π Project Structure
1
2
3
4
5
6
7
8
9
10
11
quiz_maker/
βββ raw_pdf_text/ # Extracted original text from PDFs
β βββ *.txt
βββ summarized_pdf_text/ # Agent-generated summaries
β βββ *_summary.txt
βββ json_question_answers/ # Final quizzes in JSON format
β βββ *_quiz.json
βββ main.py # Main script
βββ requirements.txt # Required dependencies
βββ .env_example # Environment variable template
βββ README.md # Documentation
π How to Run
- Clone the repository:
1 2
git clone https://github.com/enricollen/AIAgents cd openAIAgents/quiz_maker
- Create and activate a virtual environment:
1 2 3
python -m venv venv source venv/bin/activate # On Linux/MacOS venv\Scripts\activate # On Windows
- Install required dependencies:
1
pip install -r requirements.txt
- Configure environment variables: Rename the
.env_example
file in the project root and set your OpenAI key:1
OPENAI_API_KEY=your_openai_api_key
- Run the application:
1
streamlit run main.py
π GitHub Repository
Visit the project repository here for accessing the codebase (if you enjoyed this content, please consider leaving a star β).