Skip to main content

QAGeneratorLLM

A Python package for generating educational questions and answers using various LLM providers.

Features

  • Support for multiple LLM providers (Anthropic, Ollama, OpenAI, XAI)
  • Generate both Multiple Choice Questions (MCQ) and Open-Ended Questions
  • Choose between structured dataclass or raw JSON output formats
  • Batch processing support
  • File-based context input

Installation

pip install qageneratorllm

Usage

from qageneratorllm import QuestionGenerator, LLMProviderType, QuestionType, OutputType

# Initialize with default settings (Ollama + Open-Ended Questions)
generator = QuestionGenerator()

# Generate open-ended questions from text
result = generator.invoke("Your context text here")

# Generate Multiple Choice Questions using OpenAI
generator = QuestionGenerator(
    provider_type=LLMProviderType.OPENAI,
    question_type=QuestionType.MCQ
)
result = generator.invoke("Your context text here")

# Generate from file
result = generator.invoke_from_file("path/to/your/file.txt")

# Generate with JSON output instead of dataclass
generator = QuestionGenerator(
    question_type=QuestionType.MCQ,
    output_type=OutputType.JSON
)
result = generator.invoke("Your context text here")
# result will be a dictionary instead of a Pydantic model

Command Line Usage

# Basic usage
python -m qageneratorllm.generator --input input.txt --output questions.json

# Generate MCQs in batch mode from a folder of text files
python -m qageneratorllm.generator --input texts_folder/ --output results/ --batch --questions 5 --output-type json

Gradio Interface

The package includes a Gradio web interface for interactive question generation:

# Launch the Gradio app
python -m qageneratorllm.gradio_app

With the Gradio interface, you can:

  • Upload documents (.txt, .md, .pdf)
  • View document chunks separated by headers
  • Filter chunks by header level
  • Select specific chunks for question generation
  • Choose question type (MCQ or open-ended)
  • Select LLM provider
  • Generate questions interactively

Environment Variables

  • ANTHROPIC_MODEL_NAME: Anthropic model name (default: claude-3-sonnet-20240229)
  • OLLAMA_MODEL_NAME: Ollama model name (default: qwen2.5)
  • OPENAI_MODEL_NAME: OpenAI model name (default: gpt-4o)
  • XAI_MODEL_NAME: XAI model name (default: grok-beta)

License

MIT

Metadata

Release files for qageneratorllm 0.1.3

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

Source distribution (sdist)

Source distribution for qageneratorllm 0.1.3
File Size Uploaded
qageneratorllm-0.1.3.tar.gz 209.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qageneratorllm 0.1.3
File Interpreter ABI Platform
qageneratorllm-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 222.5 kB

Release files / qageneratorllm-0.1.3.tar.gz

Download URL qageneratorllm-0.1.3.tar.gz
Size 209.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d7eaaddb5bca0c428af65b1d701089b529a75c6fa71258484801fc7da36cfa89
BLAKE2b-256 checksum
How to use checksums
5b75573563056b5ec67e73663a653695c6d06803661730be9f8123e0996ee228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2025.

Transparency log

Release files / qageneratorllm-0.1.3-py3-none-any.whl

Download URL qageneratorllm-0.1.3-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3a97b3e84d4189ee6de72c3d630da12047a34c977ee8f1bb7f9099ee0c2eb28
BLAKE2b-256 checksum
How to use checksums
7fa5685950afaa238b03fd38d7ca5db9544d2bb1285063eacee00d03210e5264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.0.1

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