Skip to main content

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


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)

Uploaded Source

Built Distribution

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

django_crew_tools-1.0.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

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

Hashes for django_crew_tools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1e7676d41dfcfc5ff9a0a63640c8766cb36c16c20b39b1b92b124e3ee81ba273
MD5 50d43f7ea470fa41ffb9d5a5c58d41b1
BLAKE2b-256 f9da0955fee550ff811b84b9113e2d49073ecf41a579d299d920e94375d41dce

See more details on using hashes here.

File details

Details for the file django_crew_tools-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_crew_tools-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eadaf937022f386aba675e20e61dddd41102ab1693695eeae3fbf392f5c18f1e
MD5 0526ee31c63e134346e89805b0fc94a1
BLAKE2b-256 d934c3a406401711de34a38249d0708c8bd9fd23081f262717671b46926ebc2a

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