Skip to main content

AI support for your django app.

Project description

django-ai-support

This library is powered by langchain and langgraph to make easy AI support for your online shop or any website you want to create with Django.

This is used Agent workflow

Get started

settings

Settings should be something like this

AI_SUPPORT_SETTINGS = {
    "TOOLS": [],
    "SYSTEM_PROMPT": "You are the supporter of a bookstore website.",
    "LLM_MODEL": model,
}

TOOLS: tools are for your AI model.

SYSTEM_PROMPT: This is important for your AI support, but the default prompt is: You are the supporter of a bookstore website. As you see.

LLM_MODEL: your chat model. like this:

model = init_chat_model("gemini-2.5-flash", model_provider="google_genai")

see more

Be careful: LLM_MODEL can not be None.

config

Additionally, you can integrate your tools within your apps and add them to TOOLS.

For example, I have an app with the name of book. and this is inside of my tools.py file:

from langchain_core.tools import tool

from .models import Book

@tool(description="this is to get list of book with a price")
def get_books_with_price(price:int) -> str:
    """
    get book with input price

    Args:
        price (int): price. in dollars

    Returns:
        str: list of books.
    """
    text = ""

    for book in Book.objects.filter(price=price).select_related("author"):
        book_detail = f"book name: {book.name}, book price: {book.price}, Author: {book.author.first_name} {book.author.last_name}"
        text += book_detail + "\n"

    return text

After that, I can add this tool easily. This is inside my apps.py file:

from django.apps import AppConfig


class BookConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'book'

    def ready(self):
        from .tools import get_books_with_price as  my_tool
        from django_ai_support.conf import append_tools

        append_tools([my_tool])

read more about tool calling in langchain

API

Now, you can use the chat API to talk with your AI support:

from django.urls import path

from django_ai_support.views import ChatAiSupportApi

urlpatterns = [
    path("ai/", ChatAiSupportApi.as_view())
]

swagger

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_support-0.1.9.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

django_ai_support-0.1.9-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file django_ai_support-0.1.9.tar.gz.

File metadata

  • Download URL: django_ai_support-0.1.9.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_ai_support-0.1.9.tar.gz
Algorithm Hash digest
SHA256 58b1131ebc0155cf2608c0ff4ac6863b42b5cf47cbc627e38dcbe254cacf8ba1
MD5 1447165b5e0ef9815e0b923fcf93c1e7
BLAKE2b-256 f440c01294e07664362d705ff9825beeae3c1920cd78cf265eaf381239edea24

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ai_support-0.1.9.tar.gz:

Publisher: release-pypi.yml on EmadDeve20/django-ai-support

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_ai_support-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ai_support-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5fa0d8b30bf68fb84a2f8b4bbb9db6c5f9c4887c08240d0eed2a505522389d40
MD5 d714dd9d4e434e3cb6a3080d16029f9f
BLAKE2b-256 115e350617b577b269c38e4445bbbbb1d6b3a3b620d5cd06e83a0b6d61178052

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ai_support-0.1.9-py3-none-any.whl:

Publisher: release-pypi.yml on EmadDeve20/django-ai-support

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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