Universal CrewAI tools for Django models.
Project description
django-crew-tools
django-crew-tools turns a Django model into 5 CrewAI tools: create, read, update, delete, and list.
Install
pip install django-crew-tools
Basic usage
from crewai import Agent
from django_crew_tools import ModelToolSet
from library.models import Book
class BookToolSet(ModelToolSet):
model = Book
agent = Agent(
role="Library Manager",
goal="Manage books in the Django database",
tools=BookToolSet.as_tools(),
)
Select actions
tools = BookToolSet.as_tools(actions=["create", "read", "list"])
Scoped usage
from contextvars import ContextVar
from django_crew_tools import ModelToolSet
from library.models import Book
current_user = ContextVar("current_user", default=None)
class UserBookToolSet(ModelToolSet):
model = Book
def get_queryset(self):
return Book.objects.filter(owner=current_user.get())
def inject_fields(self):
return {"owner": current_user.get()}
Output formats
class JsonBookToolSet(ModelToolSet):
model = Book
output_format = "json"
Development
Run the package test suite with:
python tests/runtests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_crew_tools-1.0.0.tar.gz
(14.2 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_crew_tools-1.0.0.tar.gz.
File metadata
- Download URL: django_crew_tools-1.0.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e7676d41dfcfc5ff9a0a63640c8766cb36c16c20b39b1b92b124e3ee81ba273
|
|
| MD5 |
50d43f7ea470fa41ffb9d5a5c58d41b1
|
|
| BLAKE2b-256 |
f9da0955fee550ff811b84b9113e2d49073ecf41a579d299d920e94375d41dce
|
File details
Details for the file django_crew_tools-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_crew_tools-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eadaf937022f386aba675e20e61dddd41102ab1693695eeae3fbf392f5c18f1e
|
|
| MD5 |
0526ee31c63e134346e89805b0fc94a1
|
|
| BLAKE2b-256 |
d934c3a406401711de34a38249d0708c8bd9fd23081f262717671b46926ebc2a
|