Transform AI ideas into production-ready applications with LangChain. This repository contains six comprehensive demos that showcase real-world use cases, from code review assistants to legal document analyzers.
π― Perfect for: Developers who want to see practical AI applications, not toy examples.
| Demo | Description | Key Features |
|---|---|---|
| π Code Review Assistant | Analyzes code for bugs and best practices | AST parsing, security analysis, performance tips |
| π± Social Media Generator | Creates platform-specific content | Multi-platform templates, tone control, hashtag optimization |
| π§ Email Campaign Builder | Multi-step marketing automation | LCEL pipelines, strategy β content generation |
| π§ Customer Service Bot | Context-aware support chatbot | Session management, conversation history, escalation |
| π¬ Research Assistant | Multi-tool research workflows | Web search, calculations, data analysis |
| βοΈ Legal Document Analyzer | Contract analysis with RAG | Vector embeddings, source attribution, legal Q&A |
git clone https://github.com/your-username/langchain-101
cd langchain-101
pip install -r requirements.txtcp .env.example .env
# Edit .env and add your OpenAI API keypython3 src/model_demo.py # Start with code review assistant
python3 src/prompt_demo.py # Try social media generator
python3 src/chain_demo.py # Build email campaigns
python3 src/memory_demo.py # Chat with customer service
python3 src/agent_demo.py # Research with AI agents
python3 src/qa_bot_demo.py # Analyze legal documentslangchain-101/
βββ src/ # Demo applications
β βββ model_demo.py # Code Review Assistant
β βββ prompt_demo.py # Social Media Generator
β βββ chain_demo.py # Email Campaign Builder
β βββ memory_demo.py # Customer Service Bot
β βββ agent_demo.py # Research Assistant
β βββ qa_bot_demo.py # Legal Document Analyzer
βββ sample_data/ # Example documents and data
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
What it does: Analyzes code snippets and provides detailed feedback on quality, security, and best practices.
πΊ Sample Output:
π Code Review Assistant Demo
==================================================
Code being reviewed:
def calculate_user_score(users):
total = 0
for i in range(len(users)):
if users[i]['score'] > 0:
total = total + users[i]['score']
else:
print("Invalid score for user: " + users[i]['name'])
return total / len(users)
==================================================
AI Review:
### 1. Overall Code Quality Assessment
The code is straightforward but has several areas for improvement regarding
error handling, performance, and adherence to best practices.
### 2. Potential Bugs or Issues
- **Division by Zero**: If the input list is empty, this will raise a ZeroDivisionError
- **KeyError Risk**: Code assumes 'score' and 'name' keys exist in user dictionaries
- **Logic Error**: Includes invalid users in average calculation
### 3. Best Practice Recommendations
- Use enumerate() instead of range(len())
- Add input validation and error handling
- Use list comprehensions for cleaner code
- Add type annotations and docstrings
### 4. Security Concerns
- Input validation missing - could lead to runtime errors
- Consider logging instead of printing for production use
### 5. Revised Code Example
[Includes a complete, improved version with proper error handling]
What it does: Creates platform-specific content optimized for Twitter, LinkedIn, and Instagram with different tones and hashtag strategies.
πΊ Sample Output:
π± Social Media Content Generator Demo
==================================================
π― TWITTER Content:
------------------------------
π Embracing #AI in remote work is transforming productivity! From automating
repetitive tasks to enhancing collaboration, the future of work is here. How has
AI improved your workflow? Share your experiences! πΌβ¨
#RemoteWork #Productivity #FutureOfWork
π― LINKEDIN Content:
------------------------------
π As the landscape of work continues to evolve, the integration of artificial
intelligence (AI) is reshaping the way we approach remote productivity. From
intelligent task automation to advanced communication tools, AI is streamlining
workflows and enhancing collaboration among distributed teams.
A recent study highlighted that organizations leveraging AI saw a 30% increase
in overall productivity, showcasing its potential to not only facilitate
efficiency but also to empower employees by minimizing repetitive tasks.
As we navigate this new era of remote work, how do you see AI shaping your
team's productivity and collaboration in the coming years? Let's discuss! π¬
π― INSTAGRAM Content:
------------------------------
π Embracing the AI Revolution in Remote Work! π
In a world where the traditional office is becoming a thing of the past,
artificial intelligence is stepping up to redefine productivity from our home
offices. π‘β¨ From smart scheduling and project management tools to AI-driven
analytics that optimize our workflows, the possibilities are endless!
π‘ Imagine this: You start your day with an AI assistant that prioritizes your
tasks, suggests the best times for meetings, and even automates routine emails...
#AI #RemoteWork #Productivity #WorkFromHome #Tech
What it does: Uses LCEL to create multi-step marketing campaigns that generate strategy, subject lines, and email content in sequence.
πΊ Click to see sample output
π§ Email Marketing Campaign Generator Demo
============================================================
Generating campaign for: AI-powered project management software
Target audience: small business owners and startup founders
Goal: increase trial sign-ups by 25%
π MARKETING STRATEGY:
------------------------------
### Marketing Strategy for AI-Powered Project Management Software
**Key Messaging Themes:**
- Empowerment Through AI: Software uses AI to make project management easier
- Smart Decision-Making: Intelligent insights and data-driven capabilities
- Collaboration Made Simple: Enhanced team collaboration and communication
- Scalability for Growth: Software grows with the business
**Pain Points to Address:**
- Overwhelmed with tasks and lack of organization
- Limited resources and tight budgets
- Poor communication within teams
- Difficulty tracking multiple projects
**Value Propositions:**
- AI-Powered Automation saves time on repetitive tasks
- Real-Time Insights for quick decision making
- User-Friendly Interface requires minimal training
- Integration with existing tools (Slack, Google Workspace)
π¬ SUBJECT LINE OPTIONS:
------------------------------
1. "Unlock Your Free TrialβBoost Productivity Now!"
2. "Struggling with Projects? Try AI Solutions Today!"
3. "Transform Your WorkflowβStart Your Free Trial!"
4. "Don't Miss Out! Experience AI Project Management!"
5. "Ready to Simplify Your Tasks? Sign Up Free!"
βοΈ FINAL EMAIL:
------------------------------
Subject: Transform Your Projects with AI β Start Your Free Trial Today!
Dear [Recipient's Name],
Are you overwhelmed by endless tasks and struggling to keep your projects on
track? It's time to empower your business with our AI-powered project
management software designed specifically for small business owners and
startup founders like you.
Imagine having the ability to automate repetitive tasks, gain real-time
insights, and enhance team collaborationβall from a user-friendly platform...
π **Start Your Free Trial Today!**
Best regards,
[Your Name]
What it does: Maintains conversation context across multiple turns, remembering customer details and providing personalized support.
πΊ Click to see sample output
π― Customer Service Chatbot Demo
============================================================
π§ Customer Service Session: customer_001
π€ Customer: Hi, I'm having trouble logging into my account. My name is Sarah Chen
and my username is [email protected]
π€ Support Agent: Hello Sarah! I'm sorry to hear that you're having trouble
logging in. Let's start by checking your username and password. Can you please
confirm the password you're using? If it's not working, we can try resetting it.
------------------------------
π€ Customer: I tried resetting my password but I'm not receiving the reset email.
This is really frustrating!
π€ Support Agent: I understand how frustrating that can be, Sarah. Let's try a
few more troubleshooting steps. Could you please check your spam or junk folder
to see if the reset email ended up there?
------------------------------
π€ Customer: I checked my spam folder already. I have an important presentation
tomorrow and need access to my files urgently.
π€ Support Agent: I'm sorry to hear about the urgency of your situation, Sarah.
To expedite this process, I recommend clearing your browser cache and cookies...
[Conversation continues with context retention throughout]
π‘ Notice how the bot:
β’ Remembers the customer's name and details
β’ Maintains context throughout the conversation
β’ Provides specific, helpful solutions
β’ Escalates appropriately when needed
What it does: Combines multiple tools (web search, calculations, data analysis) to conduct comprehensive research workflows.
πΊ Click to see sample output
π¬ Research Assistant Agent Demo
======================================================================
π Research Scenario 1: Market Analysis
============================================================
Query: I need to research the AI market. Can you search for AI market size data
and calculate the potential market value in 5 years assuming 35% annual growth
from current $328 billion?
π€ Research Assistant Response:
Based on the search results, the current global AI market size is $328 billion
in 2023 with an expected growth rate of 35.2% CAGR from 2023 to 2030.
Calculating the potential market value in 5 years with a 35% annual growth from
the current $328 billion, the estimated market value would be approximately
$1,470.76 billion.
π Research Scenario 2: Environmental Research
============================================================
Query: Research climate change statistics and analyze the trend data. What do
the numbers tell us about the urgency of action?
π€ Research Assistant Response:
The climate change statistics reveal:
- Global temperature has risen by 1.1Β°C since pre-industrial times
- CO2 levels reached 421 ppm in 2023
- Arctic sea ice declining at 13% per decade
- 83% of climate scientists agree human activities are primary cause
The data indicates significant environmental impact with accelerating trends,
emphasizing the urgency of action needed to address this global issue.
π‘ The Research Assistant can:
β’ Search for information (simulated)
β’ Perform complex calculations
β’ Analyze data trends
β’ Combine multiple tools to answer complex questions
What it does: Uses RAG (Retrieval-Augmented Generation) to analyze legal documents, extract key terms, and answer specific legal questions with source attribution.
πΊ Click to see sample output
βοΈ Legal Document Analysis System Demo
================================================================================
β
Successfully loaded and indexed: Professional Services Agreement
π Comprehensive Analysis of: Professional Services Agreement
π Analysis 1: What are the key terms and conditions outlined in this document?
--------------------------------------------------
π Answer: Key Terms and Conditions:
- Compliance with laws including GDPR and CCPA (Section 8)
- Force Majeure clause for circumstances beyond control (Section 9)
- Governing Law in the State of California (Section 10)
- IP ownership by Client upon full payment (Section 4)
- Confidentiality obligations survive termination (Section 5)
- Limited liability to total amount paid (Section 6)
- Binding arbitration for dispute resolution (Section 7)
π Source excerpts:
1. "Both parties agree to comply with all applicable federal, state, and local
laws and regulations, including data protection and privacy laws such as GDPR..."
2. "All work products, deliverables, and intellectual property created under this
Agreement shall be owned by Client upon full payment..."
π Analysis 2: What are the payment terms, fees, or financial obligations?
--------------------------------------------------
π Answer: The payment terms include a total fee of $150,000 payable in monthly
installments of $12,500. Payments are due within 30 days of invoice receipt.
Late payments may incur a 1.5% monthly service charge.
π‘ Sample Questions Answered:
β What happens if payments are late?
π¬ Late payments incur a 1.5% monthly service charge.
β How can this contract be terminated?
π¬ Either party may terminate with thirty (30) days written notice.
β Who owns the intellectual property created?
π¬ The Client owns all IP upon full payment.
π― This system can analyze:
β’ Contracts and agreements
β’ Legal policies and procedures
β’ Compliance documents
β’ Terms of service and privacy policies
β’ Employment handbooks
- LCEL Pipelines: Complex multi-step workflows using
|operator - ChatOpenAI Integration: Latest OpenAI models with proper response handling
- Memory Management: Session-based conversation history with isolation
- Vector Stores: FAISS for efficient document retrieval and semantic search
- Agent Tools: LangGraph ReAct agents with custom tool integration
- Safe Code Execution: AST-based evaluation for mathematical expressions
- Environment Variables: Secure API key management with
.envfiles - Input Validation: Comprehensive error handling and user input sanitization
- Rate Limiting: Built-in considerations for deployment
- Error Handling: Comprehensive try/catch blocks with user-friendly messages
- Logging: Structured output for monitoring and debugging
- Documentation: Extensive inline documentation and setup guides
- Start with
model_demo.pyto understand basic LLM integration - Try
prompt_demo.pyto learn prompt engineering - Explore
memory_demo.pyfor conversation management
- Build with
chain_demo.pyto master LCEL pipelines - Create agents with
agent_demo.pyfor tool integration - Implement RAG with
qa_bot_demo.pyfor document analysis
- Study error handling patterns in each demo
- Implement monitoring and logging for your use case
- Consider security and rate limiting for deployment
We welcome contributions! Here's how you can help:
- Add New Demos: Create additional real-world use cases
- Improve Documentation: Enhance setup guides and explanations
- Testing: Add more test cases and validation scenarios
- Performance: Optimize existing implementations
- π LangChain Documentation: python.langchain.com
- π€ OpenAI API: platform.openai.com
After running these demos, you'll have hands-on experience with:
- β Modern LangChain patterns
- β Real-world AI application architectures
- β Security and error handling best practices
- β Scalable application considerations
Ready to build your own AI applications? Start with any demo that matches your use case, then adapt it to your specific needs!
β Found this helpful? Give us a star and share with your network!
π¬ Questions? Open an issue or check out the troubleshooting guide.