This repository demonstrates how to build chatbots with different levels of memory capabilities using LangChain, Pinecone, and Streamlit. The project shows the evolution from a stateless chatbot to one with permanent memory storage.
- Three levels of chatbot implementation:
- Level 1: Stateless bot (No Memory) π
- Level 2: Temporary memory using session state πΉ
- Level 3: Permanent memory using Pinecone vector storage π
- Clean, modular code structure
- Built with modern AI tools and frameworks
- Complete with error handling and best practices
Before you begin, ensure you have:
- Python 3.9 or higher
- API keys for:
- Pinecone
- OpenAI (for embeddings)
- Groq (for LLM)
git clone https://github.com/spandan114/building-intelligent-chatbots.git
cd building-intelligent-chatbots
On Windows:
# Create virtual environment
python -m venv chatbotenv
# Activate virtual environment
chatbotenv\Scripts\activate
On macOS/Linux:
# Create virtual environment
python -m venv chatbotenv
# Activate virtual environment
source chatbotenv/bin/activate
pip install -r requirements.txt
Create a .env
file in the project root:
PINECONE_API_KEY=your_pinecone_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
GROQ_API_KEY=your_groq_api_key_here
- Create a Pinecone account at pinecone.io
- Create a new index with:
- Name: chat-memory
- Dimensions: 1536 (for OpenAI embeddings)
- Metric: cosine
streamlit run app.py
The application will be available at http://localhost:8501
deactivate
building-intelligent-chatbots/
βββ bot_with_pinecone_memory.py # Main application with Pinecone
βββ bot_without_memory.py # Basic bot implementation
βββ bot_with_temporary_memory.py # Bot with session state memory
βββ requirements.txt # Project dependencies
βββ .env # Environment variables (create this)
βββ README.md # This file
-
Basic Bot (
bot_without_memory.py
):streamlit run bot_without_memory.py
-
Temporary Memory Bot (
bot_with_temporary_memory.py
):streamlit run bot_with_temporary_memory.py
-
Permanent Memory Bot (
bot_with_pinecone_memory.py
):streamlit run bot_with_pinecone_memory.py
langchain
langchain-groq
langchain-pinecone
langchain-huggingface
langchain-postgres
langchain-community
langchain-core
streamlit
python-dotenv
pinecone-client
psycopg2-binary
sentence-transformers
openai
tiktoken
-
ModuleNotFoundError:
- Ensure your virtual environment is activated
- Verify all dependencies are installed:
pip install -r requirements.txt
-
API Key Errors:
- Check if your
.env
file exists and contains valid API keys - Ensure the API keys have proper permissions
- Check if your
-
Pinecone Errors:
- Verify your index is created with correct specifications
- Check if your API key has the necessary permissions
- LangChain for the amazing framework
- Pinecone for vector storage capabilities
- Streamlit for the web interface
If you found this project helpful, please consider giving it a star! It helps others discover the project and motivates us to create more content.
For questions and feedback, please open an issue in the GitHub repository.
Happy coding! π