Django AI Assistant: app to integrate Django with LLMs

Hi folks, I’m one of the authors of the library Django AI Assistant, a third-party Django app to simplify the integration of AI-powered features into your Django project. You can declare AI assistants as Python classes and quickly implement method tools the AI can use. These tools can do anything a Django view can.

Here’s a quick example of an AI assistant class:

from django_ai_assistant import AIAssistant, method_tool

class IssueTrackerAIAssistant(AIAssistant):
    id = "issue_tracker_assistant"
    name = "Issue Tracker Assistant"
    instructions = (
        "You are a issue tracker assistant. "
        "Interact with the issue DB by using the provided tools. "
        "Always refer to issue IDs as #<id>. "
    )
    model = "gpt-4o"

    @method_tool
    def get_current_assignee_email(self) -> str:
        """Get the current user's email"""
        ...

    @method_tool
    def list_issues(self) -> str:
        """List all issues"""
        ...

    @method_tool
    def create_issue(self, title: str, description: str = "", assignee_email: str = "") -> str:
        """Create a new issue.
        Assign it to a user by passing the `assignee_email` param."""
        ...

    @method_tool
    def update_issue(self, issue_id: int, title: str, description: str = "") -> str:
        """Update an issue."""
        ...

    @method_tool
    def delete_issue(self, issue_id: int) -> str:
        """Delete an issue"""
        ...

You can effectively build full applications with LLMs doing all the heavy lifting as long as the AI has access to the right functions.

We’ve included an extensive documentation and examples.
Please give it a try and let us know what you think!

4 Likes