A Django library for AI-powered data validation and cleaning.
Project description
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.",
use_async=True
)
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
django_ai_validator-0.1.1.tar.gz
(20.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_ai_validator-0.1.1.tar.gz.
File metadata
- Download URL: django_ai_validator-0.1.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aacb23b901162dfc2ba22ee1ff4de059c196f1bcffa9f52a7c3b3be92b8b612e
|
|
| MD5 |
35d6aff31702d57ff337dcd334e62b59
|
|
| BLAKE2b-256 |
6d4733164dcfc42ac5cd6f10f4b4b89f5ba5ee75d147fd26caef514c686c5c32
|
File details
Details for the file django_ai_validator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_ai_validator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4965afedb9cdb95e65a2d59412c6d38ff7d3fa6699d8961ec368c038416c3d60
|
|
| MD5 |
16566e7fbada023a0da76a87303c2483
|
|
| BLAKE2b-256 |
6cad4f53f66aa5c6c8611e13181febff32438f3b9a8bac17be04a56850010331
|