A Langchain and Streamlit powered movie search agent that helps users find and get information about movies.
- Movie search functionality with detailed information retrieval
- Integration with Google Search, DuckDuckGo and YouTube for comprehensive results
- Real-time streaming responses
- Interactive Streamlit interface
- Powered by LangChain and OpenAI for intelligent processing
The application follows a modular architecture:
┌─────────────────┐ ┌───────────────────┐ ┌───────────────────┐
│ │ │ │ │ │
│ Streamlit UI │────▶│ MovieSearchAgent │────▶│ Search Tools │
│ │ │ │ │ │
└─────────────────┘ └───────────────────┘ └───────────────────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────────┐
│ │ │ │
│ LLM Model │ │ External APIs │
│ │ │ │
└─────────────┘ └─────────────────┘
- Streamlit UI: Provides the user interface for interacting with the agent
- MovieSearchAgent: Core component that processes user queries and coordinates responses
- Search Tools: Collection of tools for retrieving information from various sources
- LLM Model: Language model that powers the agent's understanding and response generation
- External APIs: Google Search, DuckDuckGo and YouTube APIs for retrieving movie information
- Python 3.8 or higher
- API keys for:
- OpenAI or OpenRouter (for the language model)
- Google Search API
- Google Custom Search Engine ID
-
Clone the repository:
git clone https://github.com/yourusername/movie-search-agent.git cd movie-search-agent
-
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment: Windows (PowerShell):
.venv\Scripts\Activate.ps1
Mac/Linux:
source .venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file and add your API keys, you can find required keys in the .env.example file in the root of the project.
Note: Google Search API and Custom Search Engine ID are optional, you can use DuckDuckGo as a search engine.
Start the Streamlit app:
streamlit run src/streamlit.py
The application will be available at http://localhost:8501
-
Incomplete Search Results: Search queries sometimes returned incomplete information (e.g., missing movie ratings), requiring prompt engineering to get more detailed information.
-
Tool Naming Conventions: Resolved issues with function calling by implementing proper naming conventions for tools to ensure correct invocation and prompt engineering.
-
StreamlitCallBackHandler Compatibility: Overcame integration challenges between the latest LangChain agent implementation and Streamlit's callback handler by implementing a custom solution based on community contributions. Github Issue
-
API Rate Limiting: Faced rate limiting issues with the APIs, so implemented multiple providers e.g Google Search and DuckDuckGo.
- Enter a query like "Tell me about Inception"
- The agent will search for information about the movie and return details including:
- Release date
- Director and cast
- IMDB rating
- Genre
- Plot summary
- Trailer link
- Enter a query like "Compare The Matrix and Inception"
- The agent will search for information about both movies and provide a comparison
- Enter a query like "What are some good sci-fi movies from the 90s?"
- The agent will search for and recommend movies matching your criteria
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.