DEVANG-AI-AGENT - Project Documentation
š Project Overview
DEVANG-AI-AGENT is an intelligent chatbot application built with LangChain, Ollama, and Chroma Vector Store. It specializes in answering questions about Python programming by leveraging retrieval-augmented generation (RAG) and the lightweight Llama 3.2:1b language model.
šÆ Key Features
Processes and stores Python programming knowledge from PDF documents
Uses Chroma vector store with mxbai-embed-large embeddings for semantic search
Retrieves 5 most relevant documents for each query to provide context-aware answers
Powered by Llama 3.2:1b model (lightweight, efficient)
Runs locally via Ollama for privacy and offline capability
Fast response times suitable for real-time chat interactions
Modern dark-themed chat interface
Real-time message display with smooth animations
Auto-resizing text input area
Connection status indicator
Responsive design supporting all devices
Combines document retrieval with LLM capabilities
Ensures answers are grounded in actual Python documentation
Reduces hallucinations through context-based responses
š How to Operate
Installation & Setup
3.Download and install Ollama
Pull the required models:
Prepare Your PDF Document
Place a Python programming PDF file in the project directory
Default filename: Python_(programming_language).pdf
Update the PDF_PATH variable if using a different filename
4.Run the Application
python app.py
Server starts at http://localhost:5000
Open in your web browser
Using the Chatbot
Ask Questions
Type your Python-related questions in the text input field
Press Enter to send (or Shift+Enter for new line)
Read Responses
The AI retrieves relevant Python documentation
Generates contextual answers based on retrieved content
Responses appear in the chat interface
Monitor Status
Green dot = Connected and ready
Red dot = Connection failed; restart the server
PDF Loading ā Extract all pages from document
Text Chunking ā Split into 1000-character chunks with 200-character overlap
Embedding ā Convert chunks to vector embeddings using mxbai-embed-large
Vector Storage ā Store in Chroma database at ./chroma_python_docs_db
Query Processing ā Retrieve top 5 similar documents for user questions
Response Generation ā LLM generates answer using retrieved context
Frontend Components
HTML/CSS ā Responsive chat UI with dark theme
JavaScript ā Real-time message handling, auto-resize textarea, connection status
Auto-scroll ā Chat automatically scrolls to latest message
Loading Indicator ā Shows "Thinking..." animation during processing
Data Processing Pipeline
PDF Loading ā Extract all pages from document
Text Chunking ā Split into 1000-character chunks with 200-character overlap
Embedding ā Convert chunks to vector embeddings using mxbai-embed-large
Vector Storage ā Store in Chroma database at ./chroma_python_docs_db
Query Processing ā Retrieve top 5 similar documents for user questions
Response Generation ā LLM generates answer using retrieved context
Frontend Components
HTML/CSS ā Responsive chat UI with dark theme
JavaScript ā Real-time message handling, auto-resize textarea, connection status
Auto-scroll ā Chat automatically scrolls to latest message
Loading Indicator ā Shows "Thinking..." animation during processing
š API Endpoints
GET /
Serves the main chatbot UI (HTML interface)
Response: Full HTML page
POST /query
Accepts user questions and returns AI responses
Request Body:
{
"question": "How do I use decorators in Python?"
}
Response:
{
"answer": "Decorators are functions that modify or enhance other functions..."
}
Error Response:
{
"error": "Error message description"
}
š¾ File Structure
project_directory/
āāā app.py # Main Flask application
āāā Python_(programming_language).pdf # Knowledge base PDF
āāā chroma_python_docs_db/ # Vector database (auto-created)
ā āāā [Chroma index files]
āāā [Requirements can be in requirements.txt]
š Troubleshooting
PDF Not Found
Ensure PDF file is in the project directory with correct name
If missing, system loads existing vector database if available
Ollama Models Not Found
Run ollama pull llama3.2:1b and ollama pull mxbai-embed-large
Ensure Ollama service is running in background
Connection Failed
Check if Flask server is running on port 5000
Ensure Ollama is running and accessible
Check firewall settings
Slow Responses
First query may be slower as models load into memory
Subsequent queries are faster
Close other applications to free up system resources
⨠Unique Strengths
ā
Privacy-Focused - All processing happens locally, no data sent to external servers
ā
Context-Aware - Combines specific document knowledge with general LLM understanding
ā
Lightweight - Uses 1b parameter model suitable for standard hardware
ā
No API Keys Required - Run completely offline without cloud dependencies
ā
Fast Development - Built with LangChain for quick prototyping and deployment
š Security Notes
Application runs on 0.0.0.0 - accessible from any device on the network
CORS is enabled for cross-origin requests
No authentication layer (for development/local use)
For production, add authentication and restrict access