Skip to content

Evolve your chatbot's memory from goldfish 🐠 to elephant 🐘! This project demonstrates how to build increasingly sophisticated chatbots with different memory capabilities

Notifications You must be signed in to change notification settings

spandan114/building-intelligent-chatbots

Repository files navigation

Building Intelligent Chatbots

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.

Python Streamlit LangChain Pinecone

🌟 Features

  • 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

πŸ› οΈ Prerequisites

Before you begin, ensure you have:

  • Python 3.9 or higher
  • API keys for:
    • Pinecone
    • OpenAI (for embeddings)
    • Groq (for LLM)

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/spandan114/building-intelligent-chatbots.git
cd building-intelligent-chatbots

2. Set Up Virtual Environment

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

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment Variables

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

5. Set Up Pinecone

  1. Create a Pinecone account at pinecone.io
  2. Create a new index with:
    • Name: chat-memory
    • Dimensions: 1536 (for OpenAI embeddings)
    • Metric: cosine

6. Run the Application

streamlit run app.py

The application will be available at http://localhost:8501

7. Deactivate Virtual Environment When Done

deactivate

πŸ“ Project Structure

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

πŸ”§ Available Implementations

  1. Basic Bot (bot_without_memory.py):

    streamlit run bot_without_memory.py
  2. Temporary Memory Bot (bot_with_temporary_memory.py):

    streamlit run bot_with_temporary_memory.py
  3. Permanent Memory Bot (bot_with_pinecone_memory.py):

    streamlit run bot_with_pinecone_memory.py

πŸ“ Requirements

langchain
langchain-groq
langchain-pinecone
langchain-huggingface
langchain-postgres
langchain-community
langchain-core
streamlit
python-dotenv
pinecone-client
psycopg2-binary
sentence-transformers
openai
tiktoken

πŸ› Troubleshooting

  1. ModuleNotFoundError:

    • Ensure your virtual environment is activated
    • Verify all dependencies are installed: pip install -r requirements.txt
  2. API Key Errors:

    • Check if your .env file exists and contains valid API keys
    • Ensure the API keys have proper permissions
  3. Pinecone Errors:

    • Verify your index is created with correct specifications
    • Check if your API key has the necessary permissions

πŸ‘ Acknowledgments

✨ Star the Repository

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.

πŸ“§ Contact

For questions and feedback, please open an issue in the GitHub repository.

Happy coding! πŸš€

About

Evolve your chatbot's memory from goldfish 🐠 to elephant 🐘! This project demonstrates how to build increasingly sophisticated chatbots with different memory capabilities

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages