Skip to main content

Django Langchain

What's this ?

This package aims to provide integration between LangChain and Django.

This is very early and the current stage is : alpha

Compatibility

LangChain is moving at a fast pace and interfaces may change. Version pinning is not enforced at the time to be able to use latest releases.

This package is built using

  • LangChain v0.0.229
  • Django 4.2
  • Python 3.9

Database requirements

You have to use a pgvector-enabled Postgresql database

Roadmap

Never ending todo :

  • Base document models (chunks and sources)
  • A LangChain-compliant document store
  • Embeddings are computed via SourceDocument.parse_file
  • Bare-bone admin management interface
  • Serializers (output) to use with Django REST Framework
  • Comprehensive set of utilities binding LLM & chains
  • (TBC)Serializers (input) to use with Django REST Framework
  • (TBC) Add support for celery or other async queuing system
  • (TBC) Add support for data visualization in django admin

Quickstart

Using the admin site

  1. Store a file in SourceDocument model
  2. Perform the admin action Parse and index file

  1. Check for DocumentChunk instances

  1. Perform a similarity search using Django's admin built-in search (returns 5 most relevant results)

Using the console

from django_langchain.models import SourceDocument

source_doc = SourceDocument(title='< Title >', file='< /path/to/file/ >')
source_doc.save()

#: This could take some time and some non-trivial amount of RAM
source_doc.parse_file()
print(source_doc.documentchunk_set.count())
from django_langchain.models import DocumentChunk, DocumentChunkStore

# Perform a similarity search
queryset = DocumentChunk.objects.search('< query >', max_results=5)

# Or using DocumentStore Langchain interface

store = DocumentChunkStore()
source, doc = store.search("< query >")

print(doc.metadata)
print(doc.page_content)

Release files for django-langchain 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-langchain 0.0.1
File Size Uploaded
django-langchain-0.0.1.tar.gz 234.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-langchain 0.0.1
File Interpreter ABI Platform
django_langchain-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 241.4 kB

Release files / django-langchain-0.0.1.tar.gz

Download URL django-langchain-0.0.1.tar.gz
Size 234.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c6ea3aa79a87adcceb77c4db38b78b642c9d899d3b5e4abcd170770278054e4c
BLAKE2b-256 checksum
How to use checksums
3e46437238539fcc35bb594e1ecc0d428ca21c5388c6dcd1f9e55fcba0abc8bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / django_langchain-0.0.1-py3-none-any.whl

Download URL django_langchain-0.0.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e22aa92f1900a7fcf6f16a910cb8fe955718c3a79bc7e13127f2db8c390f185c
BLAKE2b-256 checksum
How to use checksums
cc7b07b1be792631fcff0012af4b8261a9161fb0690ddd5caca91838576b223a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page