AI Chatbot is a Retrieval-Augmented Generation (RAG) solution designed to provide accurate and context-aware answers from a company's internal knowledge base. Built using Google Gemini, LangChain, FAISS, and Streamlit, the application retrieves relevant information from approved business documents and generates reliable responses based on that context. The solution helps organizations streamline information access, reduce repetitive inquiries, and ensure consistent communication across teams. By combining semantic search with advanced language models, users can interact with company knowledge through a simple and intuitive conversational interface.
- Python 3.10 or above
- Google Gemini API Key
git clone https://github.com/archna13/RAG-Powered-Chatbot-using-Generative-AI.gitpython -m venv .venv.venv\Scripts\activate # Windows
source .venv/bin/activate # Linux/Macpip install -r requirements.txtCreate a .env file in the project root directory.
GOOGLE_API_KEY=your_google_api_keystreamlit run app.pyThe chatbot provides accurate and context-aware responses based on information available within the organization's approved knowledge base. This enables users to access relevant company information through a conversational interface.
The application combines semantic search with Generative AI to retrieve relevant information before generating a response. This approach helps the chatbot provide responses that are grounded in the available company knowledge.
The application uses Gemini 2.5 Flash for response generation and Gemini Embedding 2 Preview for creating embeddings. These Gemini models support both the retrieval and response-generation stages of the RAG workflow.
The system uses FAISS to perform vector similarity search across the stored knowledge base embeddings. This allows the application to identify and retrieve the most relevant content for a user's query.
The application provides a clean and user-friendly conversational interface using Streamlit. Users can interact with the company knowledge base through a simple chat experience while maintaining session history.
-
Knowledge Base Loading: The application reads company information from the configured knowledge base file. This information serves as the primary source of knowledge for retrieving relevant context during conversations.
-
Document Chunking: The loaded content is divided into smaller, overlapping text chunks to make the information easier to process and retrieve. Overlapping chunks help preserve relevant context between different sections of the knowledge base.
-
Embedding Generation: Each text chunk is converted into a vector representation using the Gemini Embedding 2 Preview model. These embeddings capture the semantic meaning of the content and enable similarity-based retrieval.
-
Vector Storage: The generated embeddings are stored in a FAISS vector database for efficient similarity search. The stored vectors allow the system to quickly identify relevant knowledge based on a user's query.
-
User Query Processing: When a user submits a question, the query is converted into an embedding using the same embedding approach. The resulting vector is then used to search for relevant information within the stored knowledge base.
-
Context Retrieval: The system compares the query embedding with the stored vectors and retrieves the most relevant knowledge base chunks. These retrieved chunks provide the context required for generating an appropriate response.
-
Response Generation: The retrieved context is combined with the user's query and provided to Gemini 2.5 Flash. The model uses the retrieved information to generate a relevant response based on the available company knowledge.
-
Chat Response Delivery: The validated response is displayed through the Streamlit chat interface. The conversation is also maintained within the session history to provide a continuous chat experience.
| Component | Technology |
|---|---|
| User Interface | Streamlit |
| Large Language Model | Gemini 2.5 Flash |
| Embedding Model | Gemini Embedding 2 Preview |
| Framework | LangChain |
| Vector Database | FAISS |
| Programming Language | Python |
| Environment Management | python-dotenv |
AI Chatbot provides a practical and scalable approach to enterprise knowledge retrieval by combining semantic search and generative AI. The solution transforms static documentation into an interactive knowledge platform, enabling faster access to information, improved productivity, and a consistent user experience across the organization.