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.11.tar.gz (19.8 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.11-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_ai_support-0.1.11.tar.gz
  • Upload date:
  • Size: 19.8 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.11.tar.gz
Algorithm Hash digest
SHA256 fc94d8d93d2c7eb401f8865d2db57a5cd30e335a34c8b44e20e7dae098825c0d
MD5 6f3825d1c693bf79d9b42e87bdf9b8f6
BLAKE2b-256 c8e102b6d48e2b860d6d2fbf602053c1abc94d45c4f156595d5a70ece689f3e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ai_support-0.1.11.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.11-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ai_support-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 84a51643d1e13fe0e1bbb00e2973f94c4137ad84c73a98c81e3ba4b9da2f2a06
MD5 a35daac314a2ef2913bf8368a6e2b921
BLAKE2b-256 56dc74bcd295d78720741a3cf7633d0fed2520822c0f9e6d45fa85b8c8cbe888

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ai_support-0.1.11-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