Skip to main content

Validator for LLM7 chat completion requests with Pydantic and model ID constraints.

Project description

PyPI version License: MIT Downloads LinkedIn

llm7-validator

llm7-validator is a Python package designed to validate message structures sent to LLM7-compatible chat completion APIs. It ensures that model names, messages, and attachments conform to the expected structure and size constraints.

Installation

To install llm7-validator, use pip:

pip install llm7-validator

Usage

Here is a minimal example of how to use it:

from llm7_validator import validate_chat_completion_request

check = validate_chat_completion_request({
    "model": "open-mistral-7b",
    "json_mode": True,
    "messages": [
        {"role": "system", "content": "hj"},
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is this image?"},
                {"type": "image_url", "image_url": "https://example.com/image.png"},
            ],
        },
    ],
})

print(check)

Features

  • Verifies message format (role, content, etc.)

  • Validates model names against a dynamically fetched list from llm7-models.json

  • Checks:

    • Image URLs have allowed extensions (.png, .jpg, etc.)
    • Base64 image content length
    • Total request size (max 5 MB)
    • Required fields and optional tuning parameters
  • Uses cached HTTP responses for model list with a 5-minute expiration

Requirements

  • Python ≥ 3.10
  • pydantic==2.11.5
  • requests-cache==1.2.1

Contributing

Contributions, issues, and feature requests are welcome! Please visit the GitHub repo to get started.

License

llm7-validator is licensed under the MIT License.

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

llm7_validator-2025.6.110528.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

llm7_validator-2025.6.110528-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file llm7_validator-2025.6.110528.tar.gz.

File metadata

  • Download URL: llm7_validator-2025.6.110528.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.11

File hashes

Hashes for llm7_validator-2025.6.110528.tar.gz
Algorithm Hash digest
SHA256 4885fdeaa7805574802450abd6fb814bd4d1944b785bd22e653a6c06b20f6060
MD5 8b6a282e675042284576cd8985ab49f1
BLAKE2b-256 f30acc2c2646ef309edf66e95b577f999aadf1d85f36b6ff4fed5dbff17c331f

See more details on using hashes here.

File details

Details for the file llm7_validator-2025.6.110528-py3-none-any.whl.

File metadata

File hashes

Hashes for llm7_validator-2025.6.110528-py3-none-any.whl
Algorithm Hash digest
SHA256 a4bed50051616e34ee28f38cbaf98a42e5e635ca4abf1cbf055149e6ba722838
MD5 97ff3910a8dccad6dcd0c82764d972de
BLAKE2b-256 6e9954288e9a1f5f868debda845d75adf1914cf5ca1b99de918e069b41853a50

See more details on using hashes here.

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