A conversational AI-powered movie search and recommendation chat assistant. Features structured natural language query parsing, strict metadata-driven hybrid vector search via Typesense, parallel live streaming availability enrichment from the Movie of the Night (MOTN) API, conversational recommendation synthesis, and a real-time chat interface built with Chainlit.
- Python 3.10+
- LangChain (for AI orchestration)
- Typesense (for hybrid vector & keyword search)
- Chainlit (for the real-time chat UI)
- OpenAI (
gpt-4o-mini&text-embedding-3-smallfor parser/recommendation engines) - Docker (for running Typesense)
- Python 3.10+ installed
- Docker (to run Typesense)
- OpenAI API Key
- Movie of the Night API Key (RapidAPI)
- Kaggle TMDB 5000 Movies Dataset
git clone https://github.com/typesense/code-samples.git
cd typesense-langchain-ai-searchCreate a virtual environment and install the required Python packages:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtStart Typesense locally using Docker:
docker run -d \
-p 8108:8108 \
-v typesense-data:/data \
typesense/typesense:26.0 \
--data-dir /data \
--api-key=xyz \
--enable-corsCreate a .env file in the root directory:
# Typesense Configuration
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
TYPESENSE_API_KEY=xyz
TYPESENSE_COLLECTION_NAME=movies
# OpenAI Configuration
OPENAI_API_KEY=your-openai-api-key
LLM_MODEL=gpt-4o-mini
LLM_BASE_URL=https://api.openai.com/v1
# Movie of the Night API Configuration
MOTN_API_KEY=your-movie-of-the-night-api-key- Download
tmdb_5000_movies.csvandtmdb_5000_credits.csvfrom the TMDB 5000 Movie Dataset on Kaggle. - Create a folder named
data/at the root of the project and place both CSV files inside it. - Run the seeding script to clean, vectorize, and import the movies into Typesense:
python seed.py(Note: When seeding large datasets in production, be mindful of OpenAI embedding costs. Typesense also supports built-in, local machine learning models like SentenceTransformers to generate embeddings locally).
Start the Chainlit server:
chainlit run app/main.py --watchOpen http://localhost:8000 in your browser. You can now chat with your movie database using natural language!
├── app/
│ ├── core/
│ │ ├── __init__.py
│ │ ├── env.py # Environment variable utility functions
│ │ ├── models.py # Model configurations (LLM & Embeddings)
│ │ └── typesense.py # Typesense client connection pool
│ ├── logic/
│ │ ├── __init__.py
│ │ ├── query_parser.py # Pydantic parsing of query into structured filters
│ │ └── recommendation.py # AI conversational recommendation synthesis
│ ├── services/
│ │ ├── __init__.py
│ │ └── motn.py # LangChain @tool fetching live streaming providers
│ ├── public/
│ │ └── langchain.png # UI Assets
│ └── main.py # Chainlit handlers & query orchestrator
├── data/ # Datasets folder (git-ignored)
├── .gitignore
├── requirements.txt
├── seed.py # Cleaning & ingestion script
└── README.md