llm-contracts


Namellm-contracts JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryLLM Output Validation, Linting, and Assertion Layer
upload_time2025-07-26 12:08:26
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords llm validation linting ai schema contracts
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # llm-contracts

![PyPI version](https://img.shields.io/pypi/v/llm-contracts)
![Python](https://img.shields.io/badge/python-3.8+-blue)
![License](https://img.shields.io/github/license/Maxamed/llm-contract)
![Tests](https://img.shields.io/badge/tests-84%25%20coverage-brightgreen)
![Build Status](https://img.shields.io/badge/build-passing-brightgreen)

> 🛡️ **"ESLint + Pytest" for AI responses** — Catch LLM mistakes before they reach production.  
> Schema validation, content linting, and professional reports for any LLM.

---

## 📦 Install

```bash
pip install llm-contracts
```

---

## ⚡ Why `llm-contracts`?

LLMs are **fluent, confident, and totally wrong** just often enough to break your app.

- **Air Canada's chatbot** promised non-existent bereavement fares → Legal action
- **CNET's AI** published financial advice with wrong interest rates → Public corrections  
- **ChatGPT lawyer** submitted fake legal citations in court → Professional sanctions

`llm-contracts` validates every AI response **before** it causes problems.

---

## 🚀 Quick Start

### CLI
```bash
# Validate AI output against schema
llm-validate output.json --schema schema.yaml

# Generate professional reports
llm-validate output.json --schema schema.yaml --html-report report.html
```

### Python API
```python
from llm_contracts import contracts

# Validate output against schema
result = contracts.validate(data, "schema.yaml")

if not result.is_valid:
    print("AI failed validation:")
    for error in result.errors:
        print(f"  - {error}")

# Generate reports
contracts.generate_report(result, "report.html", "schema.yaml", format="html")
```

---

## ✅ Key Features

* **Schema Validation** — Ensure proper JSON/YAML structure and data types
* **Content Linting** — Check keywords, tone, word count, patterns, quality rules  
* **Professional Reports** — Beautiful HTML and Markdown validation reports
* **Framework Agnostic** — Works with OpenAI, Anthropic, local models, any LLM
* **CLI + Python API** — Use in scripts or integrate into applications
* **Zero Vendor Lock-in** — Pure validation logic, no external API calls required

---

## 📋 Example Schema

```yaml
schema:
  title:
    type: str
    min_length: 10
  description:
    type: str
    min_length: 100

rules:
  - keyword_must_include: ["quality", "premium"]
  - keyword_must_not_include: ["cheap", "defective"]
  - no_placeholder_text: "\\[YOUR_TEXT_HERE\\]"
  - word_count_min: 100
  - word_count_max: 500
```

**Result:** Every AI response gets validated before reaching your users. **No more silent failures.**

---

## 📚 Documentation & Links

* 📖 [Complete Documentation & Whitepaper](https://maxamed.github.io/llm-contract/)
* 🚀 [Getting Started Guide](https://maxamed.github.io/llm-contract/getting-started)
* 💡 [Real-World Examples](https://maxamed.github.io/llm-contract/examples)
* 🛠 [GitHub Source](https://github.com/Maxamed/llm-contract)
* 🐛 [Report Issues](https://github.com/Maxamed/llm-contract/issues)

---

## 🤝 Contributors

**Created by [Mohamed Jama](https://www.linkedin.com/in/mohamedjama/)** - Built for developers shipping AI features in production.

**Major Contributors:**
- **[Abdirahman Attila](https://github.com/Attili-sys)** - Frontend web interface, comprehensive documentation website, enhanced testing suite, and Jekyll/GitHub Pages setup

We welcome contributions! See [CONTRIBUTING.md](https://github.com/Maxamed/llm-contract/blob/main/CONTRIBUTING.md) for guidelines.

---

## 🏷 License

MIT © Mohamed Jama - see [LICENSE](https://github.com/Maxamed/llm-contract/blob/main/LICENSE) file for details.

---

**Stop hoping your AI gets it right. Start knowing it does.** 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llm-contracts",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "llm, validation, linting, ai, schema, contracts",
    "author": null,
    "author_email": "Mohamed Jama <mohamed.jama@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/71/b7/81c694be887392b0cba0f7b1c0534a6a15cc9da380cadd4462703a9a1d81/llm_contracts-1.0.0.tar.gz",
    "platform": null,
    "description": "# llm-contracts\n\n![PyPI version](https://img.shields.io/pypi/v/llm-contracts)\n![Python](https://img.shields.io/badge/python-3.8+-blue)\n![License](https://img.shields.io/github/license/Maxamed/llm-contract)\n![Tests](https://img.shields.io/badge/tests-84%25%20coverage-brightgreen)\n![Build Status](https://img.shields.io/badge/build-passing-brightgreen)\n\n> \ud83d\udee1\ufe0f **\"ESLint + Pytest\" for AI responses** \u2014 Catch LLM mistakes before they reach production.  \n> Schema validation, content linting, and professional reports for any LLM.\n\n---\n\n## \ud83d\udce6 Install\n\n```bash\npip install llm-contracts\n```\n\n---\n\n## \u26a1 Why `llm-contracts`?\n\nLLMs are **fluent, confident, and totally wrong** just often enough to break your app.\n\n- **Air Canada's chatbot** promised non-existent bereavement fares \u2192 Legal action\n- **CNET's AI** published financial advice with wrong interest rates \u2192 Public corrections  \n- **ChatGPT lawyer** submitted fake legal citations in court \u2192 Professional sanctions\n\n`llm-contracts` validates every AI response **before** it causes problems.\n\n---\n\n## \ud83d\ude80 Quick Start\n\n### CLI\n```bash\n# Validate AI output against schema\nllm-validate output.json --schema schema.yaml\n\n# Generate professional reports\nllm-validate output.json --schema schema.yaml --html-report report.html\n```\n\n### Python API\n```python\nfrom llm_contracts import contracts\n\n# Validate output against schema\nresult = contracts.validate(data, \"schema.yaml\")\n\nif not result.is_valid:\n    print(\"AI failed validation:\")\n    for error in result.errors:\n        print(f\"  - {error}\")\n\n# Generate reports\ncontracts.generate_report(result, \"report.html\", \"schema.yaml\", format=\"html\")\n```\n\n---\n\n## \u2705 Key Features\n\n* **Schema Validation** \u2014 Ensure proper JSON/YAML structure and data types\n* **Content Linting** \u2014 Check keywords, tone, word count, patterns, quality rules  \n* **Professional Reports** \u2014 Beautiful HTML and Markdown validation reports\n* **Framework Agnostic** \u2014 Works with OpenAI, Anthropic, local models, any LLM\n* **CLI + Python API** \u2014 Use in scripts or integrate into applications\n* **Zero Vendor Lock-in** \u2014 Pure validation logic, no external API calls required\n\n---\n\n## \ud83d\udccb Example Schema\n\n```yaml\nschema:\n  title:\n    type: str\n    min_length: 10\n  description:\n    type: str\n    min_length: 100\n\nrules:\n  - keyword_must_include: [\"quality\", \"premium\"]\n  - keyword_must_not_include: [\"cheap\", \"defective\"]\n  - no_placeholder_text: \"\\\\[YOUR_TEXT_HERE\\\\]\"\n  - word_count_min: 100\n  - word_count_max: 500\n```\n\n**Result:** Every AI response gets validated before reaching your users. **No more silent failures.**\n\n---\n\n## \ud83d\udcda Documentation & Links\n\n* \ud83d\udcd6 [Complete Documentation & Whitepaper](https://maxamed.github.io/llm-contract/)\n* \ud83d\ude80 [Getting Started Guide](https://maxamed.github.io/llm-contract/getting-started)\n* \ud83d\udca1 [Real-World Examples](https://maxamed.github.io/llm-contract/examples)\n* \ud83d\udee0 [GitHub Source](https://github.com/Maxamed/llm-contract)\n* \ud83d\udc1b [Report Issues](https://github.com/Maxamed/llm-contract/issues)\n\n---\n\n## \ud83e\udd1d Contributors\n\n**Created by [Mohamed Jama](https://www.linkedin.com/in/mohamedjama/)** - Built for developers shipping AI features in production.\n\n**Major Contributors:**\n- **[Abdirahman Attila](https://github.com/Attili-sys)** - Frontend web interface, comprehensive documentation website, enhanced testing suite, and Jekyll/GitHub Pages setup\n\nWe welcome contributions! See [CONTRIBUTING.md](https://github.com/Maxamed/llm-contract/blob/main/CONTRIBUTING.md) for guidelines.\n\n---\n\n## \ud83c\udff7 License\n\nMIT \u00a9 Mohamed Jama - see [LICENSE](https://github.com/Maxamed/llm-contract/blob/main/LICENSE) file for details.\n\n---\n\n**Stop hoping your AI gets it right. Start knowing it does.** \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "LLM Output Validation, Linting, and Assertion Layer",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/Maxamed/llm-contract/issues",
        "Documentation": "https://github.com/Maxamed/llm-contract#readme",
        "Homepage": "https://github.com/Maxamed/llm-contract",
        "Repository": "https://github.com/Maxamed/llm-contract"
    },
    "split_keywords": [
        "llm",
        " validation",
        " linting",
        " ai",
        " schema",
        " contracts"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5f43e43013078e936f4b94aa1f31716a08695617347471c7af255166baf98a2f",
                "md5": "b98e60a3288fb372e5dc87012bce79cf",
                "sha256": "1041f6cb3d8f71154eefabc711559bb3940958662f67bda2e32fee9d484415ea"
            },
            "downloads": -1,
            "filename": "llm_contracts-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b98e60a3288fb372e5dc87012bce79cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20400,
            "upload_time": "2025-07-26T12:08:25",
            "upload_time_iso_8601": "2025-07-26T12:08:25.208481Z",
            "url": "https://files.pythonhosted.org/packages/5f/43/e43013078e936f4b94aa1f31716a08695617347471c7af255166baf98a2f/llm_contracts-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "71b781c694be887392b0cba0f7b1c0534a6a15cc9da380cadd4462703a9a1d81",
                "md5": "ca6797ec72e6e9f35aff462b59894d54",
                "sha256": "867e7b6c559619554e20400deadf09bb8ff046b23b876f44f4a2a0403eca5cc5"
            },
            "downloads": -1,
            "filename": "llm_contracts-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ca6797ec72e6e9f35aff462b59894d54",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 36573,
            "upload_time": "2025-07-26T12:08:26",
            "upload_time_iso_8601": "2025-07-26T12:08:26.821296Z",
            "url": "https://files.pythonhosted.org/packages/71/b7/81c694be887392b0cba0f7b1c0534a6a15cc9da380cadd4462703a9a1d81/llm_contracts-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-26 12:08:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Maxamed",
    "github_project": "llm-contract",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "llm-contracts"
}
        
Elapsed time: 1.20794s