Skip to main content

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

Project description

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qageneratorllm-0.1.2.tar.gz (207.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qageneratorllm-0.1.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file qageneratorllm-0.1.2.tar.gz.

File metadata

  • Download URL: qageneratorllm-0.1.2.tar.gz
  • Upload date:
  • Size: 207.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for qageneratorllm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7868af107005e5dd9b3a58cfdd7232ce0eb17fa2727bb01d7b036ef9da45e623
MD5 542608a1eae28892084c024712627bd6
BLAKE2b-256 727b42303dc07fd262312192ca30af6f1e9fc585708d2173a534aed84d3c7c94

See more details on using hashes here.

Provenance

The following attestation bundles were made for qageneratorllm-0.1.2.tar.gz:

Publisher: python-publish.yml on KameniAlexNea/create-dataset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qageneratorllm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: qageneratorllm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for qageneratorllm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf87125619f2dc0071a92d2081f9b155d1f9bb8754b91038b4670c83d409e97
MD5 05de217d4d2eeca2e80570a3fd5a7597
BLAKE2b-256 0d5aa47b1f27ba83c24b564a93f7a49124c3d69997672a077023f74c3d75dbf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for qageneratorllm-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on KameniAlexNea/create-dataset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page