Skip to main content

A Django app for integrating LangChain with search capabilities

Project description

Overview

This project uses langchain (currently only OpenAI) to search a Django model. Simply use LangChainSearchMixin in your view, and let the user perform a query with the ?q= parameter. Example:

http://127.0.0.1:8000/api/jobs/?q=Engineer jobs posted after or on June 22 2025 salary minimum 40000 hybrid

The human language query will be converted to your model fields using LangChain and ChatGPT.

Installation

This project runs with uv.

pip install uv
uv sync --frozen

To add to your django project Add this to apps: 'langchain_search'

You need to also set your openai key

export OPENAI_API_KEY=....

Usage example

from .models import Job
from rest_framework import generics
from .serializers import JobSerializer
from langchain_search import LangChainSearchMixin

# Add mixin here
class JobListAPI(LangChainSearchMixin, generics.ListAPIView):
    queryset = Job.objects.all()
    serializer_class = JobSerializer

    def get(self, request, *args, **kwargs):
        return super().get(request, *args, **kwargs)

Example project: https://github.com/errietta/django-langchain-search-example

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

langchain_search_django-0.7.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

langchain_search_django-0.7.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_search_django-0.7.0.tar.gz.

File metadata

File hashes

Hashes for langchain_search_django-0.7.0.tar.gz
Algorithm Hash digest
SHA256 fefec35fbbe20bbb1010632a57d56b815578080e1a6df48fbcbdaf79cc345604
MD5 9796a7d77ece5a9be37c2a9f7142f09b
BLAKE2b-256 c9cda531cbe594b4ce0b1a6bce8b456488c40d167409008c5213842bf8c160f4

See more details on using hashes here.

File details

Details for the file langchain_search_django-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_search_django-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4276f2b095289694c967f27732c9c85c99718af6c0815be878cb19036d55e3f
MD5 c4822fa350dbc24f661c77f7b085e0f7
BLAKE2b-256 76bf8f93d39a6005c962f34742a6f42251b0b289ee3a28729ff43fa8d0a00b99

See more details on using hashes here.

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