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

# 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.2.0

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.2.0
File Size Uploaded Provenance Actions
quiz_me-0.2.0.tar.gz 207.1 kB Without provenance Details for quiz_me-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 237.3 kB

Release files / quiz_me-0.2.0.tar.gz

Download URL quiz_me-0.2.0.tar.gz
Size 207.1 kB
Tags Source
SHA-256 checksum
How to use checksums
efcc9bc6d890e8902b46d1cd480dc25fcc7b8d0e626f3dd76e9460cfa0bd361a
BLAKE2b-256 checksum
How to use checksums
fe5feabb31875b3a62fba065d23ac2d05a256471d600ae5805153626e6d72aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","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.2.0-py3-none-any.whl

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

Security for quiz-me 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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