A Retrieval-Augmented Generation (RAG) chatbot that allows you to upload company policy documents (PDF, TXT) and ask questions about them. The chatbot uses Groq, LangChain, FAISS, and Streamlit for a fast, interactive experience.
- Document Upload: Upload multiple PDF and TXT files via Streamlit UI
- Vector Search: Uses FAISS and HuggingFace embeddings for semantic search
- LLM Integration: Powered by Groq's Llama 3.3 70B model
- Web UI: Interactive Streamlit frontend with chat history
- REST API: FastAPI backend with LangServe for extensibility
- LLMops tools: LangServe
- Python 3.13 or later
- Pipenv (for dependency management)
- Groq API Key (get one at console.groq.com)
pipenv installCreate a .env file in the project root:
GROQ_API_KEY=your_groq_api_key_herepipenv run python -m uvicorn main:app --reloadThe backend will start at http://127.0.0.1:8000. You can explore the API at http://127.0.0.1:8000/docs.
pipenv run streamlit run client.pyThe Streamlit app will open at http://localhost:8501 in your browser.
- Upload Documents: Use the sidebar to upload PDF or TXT files containing your company policies.
- Process Files: Click "Process Files" to embed and index the documents.
- Ask Questions: Once processed, type your question in the chat input and get answers with source references.
Rag_Chatbot_for_company_policy/
├── main.py # FastAPI backend with RAG chain
├── client.py # Streamlit frontend UI
├── Pipfile # Pipenv dependencies
├── Pipfile.lock # Locked dependency versions
├── .env # Environment variables (not in git)
├── .gitignore # Git ignore file
├── faiss_index/ # FAISS vector store (auto-created)
└── README.md # This file
- FastAPI server with CORS enabled
- LangChain chains for RAG logic
- FAISS vector store for document retrieval
- Groq LLM for response generation
- LangServe integration for LLM as a service
- Streamlit interactive UI
- File uploader for documents
- Chat interface with message history
- Source attribution for retrieved documents
Edit main.py and modify the ChatGroq initialization:
llm = ChatGroq(
model_name="llama-3.3-70b-versatile", # Change this
groq_api_key=os.getenv("GROQ_API_KEY")
)Edit main.py and modify:
EMBEDDING_MODEL_NAME = "sentence-transformers/all-MiniLM-L6-v2" # Change thispipenv run streamlit run client.py --server.port 8502Key packages (see Pipfile for full list):
- FastAPI: Web framework
- Streamlit: UI framework
- LangChain: RAG orchestration
- Groq: LLM API
- FAISS: Vector database
- Uvicorn: ASGI server
- Pydantic: Data validation
- Ensure
GROQ_API_KEYis set in.env - Check if port
8000is already in use:lsof -i :8000(Mac/Linux) ornetstat -ano | findstr :8000(Windows)
- Verify backend is running at
http://127.0.0.1:8000 - Check
BACKEND_URLinclient.pymatches your backend address
- Ensure you uploaded and processed documents first via the Streamlit sidebar
- Check browser console for errors
-
Push your code to a GitHub repository:
git add . git commit -m "Initial commit" git push origin main
-
Go to share.streamlit.io
-
Click "New app" and connect your GitHub repository
-
Set the main file to
client.py -
Add
GROQ_API_KEYas a secret in Streamlit Cloud settings
Note: You'll need to deploy the backend separately (e.g., on Heroku, AWS, Google Cloud) or use a separate backend service.
- The FAISS index is stored locally in
faiss_index/directory - Chat history is stored in Streamlit session state and persists during the session
- The app uses CORS middleware to allow requests from any origin
This project is open source and available under the MIT License.
For issues or feature requests, please open an issue or contact the development team.