Django AI Validator
Documentation: https://mazafard.github.io/django-ai-validator/
A Django library for AI-powered data validation and cleaning.
Features
- Semantic Validation: Validate data based on meaning using LLMs.
- Automated Cleaning: Automatically clean and normalize data.
- Admin Integration: Bulk actions and status indicators in Django Admin.
- Asynchronous Support: Offload LLM calls to Celery tasks.
- Multiple Providers: Support for OpenAI, Anthropic, Gemini, and Ollama.
Installation
pip install django-ai-validator
Configuration
Add to INSTALLED_APPS:
INSTALLED_APPS = [
...
'django_ai_validator',
]
Set your API key:
# Defaults to OpenAIClient
AI_CLEANER_LLM_CLIENT = 'django_ai_validator.llm.client.OpenAIClient'
OPENAI_API_KEY = "your-api-key"
Usage
Semantic Validation
from django.db import models
from django_ai_validator.validators import AISemanticValidator
class Product(models.Model):
description = models.TextField(
validators=[
AISemanticValidator(
prompt_template="Ensure the description is marketing-friendly and contains no offensive language."
)
]
)
Automatic Cleaning
from django_ai_validator.fields import AICleanedField
class UserProfile(models.Model):
bio = AICleanedField(
cleaning_prompt="Fix grammar and remove personal contact info."
)
Admin Integration
from django.contrib import admin
from django_ai_validator.admin import AIAdminMixin
from .models import MyModel
@admin.register(MyModel)
class MyModelAdmin(AIAdminMixin, admin.ModelAdmin):
list_display = ['content', 'is_dirty']
actions = ['run_ai_cleanup_on_selected']
Manual Validation
To check if user input contains bad words:
from django_ai_validator.validators import AISemanticValidator
class Comment(models.Model):
text = models.TextField(
validators=[
AISemanticValidator(
prompt_template="Check if this text contains bad words. Return VALID if not."
)
]
)
Asynchronous Cleaning
To automatically remove personal information:
from django_ai_validator.fields import AICleanedField
class Feedback(models.Model):
message = AICleanedField(
cleaning_prompt="Remove PII.",
)
Star History
Release files for django-ai-validator 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_ai_validator-0.1.7.tar.gz | 21.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_ai_validator-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / django_ai_validator-0.1.7.tar.gz
| Download URL | django_ai_validator-0.1.7.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be73289522d62831c8d890113745fd3984912286c6d71f2b3c1e501f78c4da07
|
|
BLAKE2b-256 checksum How to use checksums |
153ac04b37b84a0c5019e3b60bc65729fba5575975fefa0195d43ae8e75eb37f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / django_ai_validator-0.1.7-py3-none-any.whl
| Download URL | django_ai_validator-0.1.7-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abab922a121c232f6d1800dc7a64361a051fddcc1de6bb9e78b7ecf6c3888fd3
|
|
BLAKE2b-256 checksum How to use checksums |
0b71c87ad4484e27e32b90b42dfbfbe59b59ba1be23e791b2ce41b50531e417d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|