Skip to main content

quiz-me

AI-powered question generation library using Langgraph flows. Generate high-quality educational questions from content or topics with optional AI supervision.

Features

  • Single & Multi-Question Generation - Generate one or multiple questions from content or topics
  • Three Question Types - Multiple choice, open-ended (with grading rubric), and fill-in-the-blank
  • Optional AI Supervision - A second model reviews and validates generated questions
  • Question Improvement - Regenerate questions based on user feedback
  • Multi-Language Support - Generate questions in any language
  • Automatic Retry Logic - Retries on validation errors or supervision rejection
  • Domain-Specific Instructions - Customize generation and supervision for your domain
  • LangChain Compatible - Works with any LangChain-compatible model

Installation

pip install quiz-me

Or with uv:

uv add quiz-me

Quick Start

from quiz_me import generate_question, SingleQuestionConfig, QuestionType

# Use any LangChain-compatible model
from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-4o-mini")

# Generate a multiple choice question
config = SingleQuestionConfig(
    content="Python is a high-level programming language...",
    question_type=QuestionType.MULTIPLE_CHOICE,
    generator_model=model,
)

result = await generate_question(config)
print(result.question.statement)
print(result.question.alternatives)
print(result.question.correct_answer)

Topic-Based Generation

Generate questions from a topic using the model's knowledge (no content required):

config = SingleQuestionConfig(
    topic="The French Revolution and its impact on European politics",
    question_type=QuestionType.MULTIPLE_CHOICE,
    generator_model=model,
)

result = await generate_question(config)

Multi-Question Generation

from quiz_me import generate_questions, MultiQuestionConfig, QuestionTypeMix

config = MultiQuestionConfig(
    content="Your educational content here...",
    num_questions=5,
    question_mix=[
        QuestionTypeMix(question_type=QuestionType.MULTIPLE_CHOICE, count=3),
        QuestionTypeMix(question_type=QuestionType.OPEN_ENDED, count=2),
    ],
    generator_model=model,
    planning_instructions="Focus on key concepts and practical applications",
)

result = await generate_questions(config)
for q in result.questions:
    print(q.statement)

With Supervision

config = SingleQuestionConfig(
    content="Medical terminology content...",
    question_type=QuestionType.MULTIPLE_CHOICE,
    generator_model=model,
    supervisor_model=model,  # Can be same or different model
    supervision_enabled=True,
    generator_instructions="Focus on pharmacology terms",
    supervisor_instructions="Verify medical accuracy",
)

result = await generate_question(config)
print(f"Approved: {result.question.approved}")

Multi-Language Support

Generate questions in any language by setting the language property:

config = SingleQuestionConfig(
    content="Python é uma linguagem de programação...",
    question_type=QuestionType.MULTIPLE_CHOICE,
    generator_model=model,
    language="Portuguese",  # All content generated in Portuguese
)

result = await generate_question(config)
# Question, alternatives, and explanation will be in Portuguese

Question Improvement

Improve an existing question based on feedback using the same pattern as supervision:

from quiz_me import improve_question

# Original question that needs improvement
original = result.question

# Create config matching the original question
config = SingleQuestionConfig(
    content="Original content...",
    question_type=original.question_type,
    generator_model=model,
)

# Improve based on feedback
improved = await improve_question(
    question=original,
    feedback="The distractors are too obvious. Make them more plausible.",
    config=config,
)
print(improved.question.statement)

Retry Configuration

Control retry behavior for generation failures:

config = SingleQuestionConfig(
    content="Your content...",
    question_type=QuestionType.MULTIPLE_CHOICE,
    generator_model=model,
    max_retries=5,                    # Default is 3
    retry_on_validation_error=True,   # Retry on Pydantic validation errors
)

Documentation

See docs/ for detailed documentation.

Development

# Install with dev dependencies
uv sync --all-extras

# Run tests
uv run pytest tests/ -v

Stack

  • Langgraph - Flow orchestration
  • Pydantic - Data validation
  • ai-prompter - Jinja-based prompt templates
  • LangChain - Model abstraction

License

MIT

Metadata

Release files for quiz-me 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quiz-me 0.1.1
File Size Uploaded
quiz_me-0.1.1.tar.gz 144.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quiz-me 0.1.1
File Interpreter ABI Platform
quiz_me-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 174.2 kB

Release files / quiz_me-0.1.1.tar.gz

Download URL quiz_me-0.1.1.tar.gz
Size 144.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d59aac7770012ae2ef7f1ab6bcc3ef91c9551cb814512f324d2bed496140a4f0
BLAKE2b-256 checksum
How to use checksums
24da3913fe5e53cbaed241214066b947c91b0928c5347336ddd5388c99338d54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / quiz_me-0.1.1-py3-none-any.whl

Download URL quiz_me-0.1.1-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8777684d1ac475b87671cee6a110b0ed63184103b548bd177532694c37665b3d
BLAKE2b-256 checksum
How to use checksums
697f7e4e117352916a480cd1c5cf27abffa1a7afd3b05e15fa45fb3f548849c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page