A modular and scalable AI chatbot project building using LangChain, FastAPI, and Streamlit. This repository demonstrates how to integrate both cloud-based LLMs (via Groq) and local LLMs (via Ollama) while providing a robust API layer and an interactive user interface.
- Multi-Model Support:
- Groq (Llama 3.3): High-performance cloud inference for detailed tasks.
- Ollama (TinyLlama): Lightweight local inference for privacy-focused use cases.
- FastAPI Backend:
/chat: General-purpose chatbot endpoint./essay: specialized endpoint for essay generation./poem: specialized endpoint for creative writing (poetry).
- Streamlit Frontend: A simple, interactive UI to chat with the local Ollama model.
- RAG Capabilities: Includes research notebooks and sample datasets for implementing Retrieval-Augmented Generation.
- LangSmith Integration: Ready for tracing and monitoring with LangChain's observability tools.
- Framework: LangChain
- API: FastAPI, LangServe, Uvicorn
- Frontend: Streamlit
- LLM Providers: Groq, Ollama
- Data Handling: FAISS (CPU), PyPDF, BeautifulSoup4
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/Chatbot-using-LangChain.git cd Chatbot-using-LangChain -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Environment Setup: Create a
.envfile in the root directory and add your API keys:GROQ_API_KEY=your_groq_api_key LANGCHAIN_API_KEY=your_langchain_api_key LANGCHAIN_TRACING_V2=true LANGCHAIN_PROJECT=Langchain Chatbot
Start the FastAPI server using Uvicorn:
python api/app.pyThe server will be available at http://localhost:8000. You can access the LangServe playground at:
http://localhost:8000/chat/playgroundhttp://localhost:8000/essay/playgroundhttp://localhost:8000/poem/playground
Launch the interactive chatbot UI:
streamlit run Chatbot/Ollama.py.
├── Chatbot/ # Streamlit application
│ └── Ollama.py
├── api/ # FastAPI backend with LangServe
│ └── app.py
├── rag/ # RAG experimentation and assets
│ ├── Simplerag.ipynb
│ ├── attention.pdf
│ ├── chain.ipynb
│ └── speech.txt
├── requirements.txt # Project dependencies
└── README.md # Documentation
This project is licensed under the MIT License - see the LICENSE file for details.