Skip to main content

A Django app for building parrot configurations

Project description

PyPI Version License Python Versions Documentation Status Tests Publish Python 🐍 distribution 📦 to PyPI

Django Polly enhances Django with Language Learning Model (LLM) capabilities, enabling AI-powered conversations, task automation, and other intelligent features in your Django projects. It uses familiar Django patterns and provides a flexible framework for customizing AI behaviors and supporting various LLM backends.

Features

  • LLM Management: Create and configure LLM instances (parrots)

  • SmartConversations: Engage in AI-powered conversations

  • WebSocket Support: Real-time communication for chat interfaces

  • Admin Interface: Easily manage parrots and conversations

  • Extensible: Designed to work with various LLM backends

Documentation

For full documentation, visit: https://django-polly.readthedocs.io

Quick Start

  1. Install django-polly and its dependencies:

    pip install django-polly
  2. Add “django_polly” and its dependencies to your INSTALLED_APPS setting in settings.py:

    INSTALLED_APPS = [
        'daphne',  # Add this before all django apps
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django_polly',  # Add this after all django apps
        'rest_framework', # Required for API views
        'django_json_widget', # Required for JSON widget in admin (optional)
        # ... your other apps ...
    ]
  3. Configure ASGI in your project’s asgi.py:

    import os
    from django.core.asgi import get_asgi_application
    from channels.routing import ProtocolTypeRouter
    from django_polly.routing import polly_asgi_routes
    
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project.settings')
    
    # Get the Django ASGI application
    django_asgi_app = get_asgi_application()
    
    # Use the Django ASGI application for HTTP requests
    polly_asgi_routes["http"] = django_asgi_app
    
    # Create the final ASGI application
    application = ProtocolTypeRouter(polly_asgi_routes)
  4. Update your settings.py with the following:

    # Add this to specify the ASGI application
    ASGI_APPLICATION = 'your_project.asgi.application'
    WSGI_APPLICATION = 'your_project.wsgi.application'
    
    # Add this for daphne
    CHANNEL_LAYERS = {
        'default': {
            'BACKEND': 'channels.layers.InMemoryChannelLayer'
        }
    }
    
    AI_MODELS_PATH = BASE_DIR / 'ai_models' # Add this to specify the path to store AI models
  5. Include the django-polly URLconf in your project urls.py:

    from django.contrib import admin
    from django.urls import path, include
    
    urlpatterns = [
        path('admin/', admin.site.urls),
        path('polly/', include('django_polly.urls')),
        # ... other URL patterns ...
    ]
  6. Run migrations:

    python manage.py migrate
  7. Download an AI model (example using Qwen2):

    python manage.py download_model "Qwen2-500M-Instruct-Q8_0.gguf" "https://huggingface.co/lmstudio-community/Qwen2-500M-Instruct-GGUF/resolve/main/Qwen2-500M-Instruct-Q8_0.gguf"
  8. Start the development server:

    python manage.py runserver

    Visit http://127.0.0.1:8000/admin/ to create parrots and http://127.0.0.1:8000/polly/ to use django-polly.

Dependencies

Django Polly supports Python 3.8 and up, and is compatible with Django 4.2 and 5.0.

Contributing

We welcome contributions! To learn more about contributing, please read our contributing docs.

Support

If you’re having issues, please let us know by opening an issue on our GitHub repository.

For larger discussions, join our mailing list.

License

The project is licensed under the AGPL-3.0 license.

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_polly-0.0.4.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

django_polly-0.0.4-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file django_polly-0.0.4.tar.gz.

File metadata

  • Download URL: django_polly-0.0.4.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for django_polly-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c0148e59d25b819a79b38c464e7c9327cbc2cf1ad05dac7c3e26c3b9477398ee
MD5 9ca6237b96cf8fe797fd2c912b767291
BLAKE2b-256 c41dc950b5438a0ad4ba64baee44b6b352df1b4755021f7a972dc175ef3cf190

See more details on using hashes here.

File details

Details for the file django_polly-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: django_polly-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 43.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for django_polly-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 91d6d6748af4fdd156a9054a7de341f2860eddd13331ee23f85951b9c2b0b790
MD5 81ac312184801ae7294d1a28db624fe8
BLAKE2b-256 ac50a51e3371c775d8e5ef0e89c652b30353d57f7be8078844058b799854942f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page