An advanced AI-powered chatbot system for industrial machine diagnostics and troubleshooting, built with Ollama (Mistral Nemo) and dynamic semantic search capabilities.
- Mistral Nemo Model: Uses Ollama with Mistral Nemo for intelligent troubleshooting responses
- RAG (Retrieval-Augmented Generation): Combines semantic search with AI generation for accurate solutions
- Context-Aware: Leverages historical maintenance data to provide relevant solutions
- Dynamic Learning: Real-time updates to the knowledge base from user contributions
- Vector Embeddings: Uses Sentence-BERT (all-MiniLM-L6-v2) for intelligent case matching
- Hybrid Search: Combines keyword matching and cosine similarity for optimal results
- Case History: Searches through past maintenance records to find similar issues
- Real-time Chat: Natural language interaction with the AI assistant
- Structured Diagnosis: Form-based troubleshooting for detailed analysis
- Multi-turn Conversations: Maintains context throughout the discussion
- User Feedback System: Collects ratings and comments to improve accuracy
- Statistics Dashboard: Tracks queries, success rates, and user contributions
- Export Functionality: Download chat history and correction submissions
- Ollama: Must be installed and running locally
- OS: Windows 10/11, Linux (Ubuntu 20.04+), or macOS
- Python: 3.8 or higher
First, install Ollama on your system. Once installed, pull the required model:
ollama pull mistral-nemogit clone https://github.com/Romilagarwal/new_chatbot.git
cd new_chatbotpython -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activatepip install flask flask-compress sentence-transformers pandas numpy scikit-learn python-dotenv pytz requestsCreate a .env file in the project root:
# Dataset path
DATABASE_PATH=mix_dataset_final.csv
# Ollama Host (default)
OLLAMA_HOST=http://localhost:11434Place your machine maintenance dataset CSV file (mix_dataset_final.csv) in the project root with the following columns:
Machine TypeMACHINE(Machine Name)Problem DescriptionRoot CauseAction Taken
python app.pyThe application will:
- Connect to the local Ollama service
- Create embeddings for the reference dataset (or load from memory)
- Start the Flask server
- Automatically open your web browser
Simply type your question in the chat interface:
"APMT machine showing alarm 203"
"How to fix welding spot machine not working?"
"Printer paper jam issue"
- Select Machine Type from dropdown
- Enter Machine Name (e.g., PRE-APMT, WELDING SPOT)
- Describe the Problem in detail
- Click Diagnose Problem
The system will:
- Find similar cases from the database
- Analyze patterns using AI
- Provide root cause analysis
- Suggest immediate actions
- Recommend preventive measures
Help improve the system by submitting your solved cases:
- Click Add Solution button
- Fill in the machine details and solution
- Submit for review
new_chatbot/
├── app.py # Main Flask application
├── ollama_model.py # Ollama API model wrapper
├── model_utils.py # RAG and dynamic learning base
├── stats_cards_updater.py # Analytics logic
├── templates/
│ └── index.html # Frontend interface
├── data/ # Generated data directory
│ ├── feedback.csv # User feedback
│ ├── user_corrections.csv # Submitted solutions
│ └── chat_logs.json # Chat history
├── mix_dataset_final.csv # Your maintenance dataset
├── .env # Environment configuration
└── README.md # This file
Mistral Nemo configuration in ollama_model.py:
- Temperature: 0.7 (troubleshooting), 0.8 (chat)
- Top-p: 0.9
Adjust in model_utils.py:
threshold = 0.60 # Similarity threshold
top_n = 3 # Number of primary results| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Main application interface |
/health |
GET | System health check |
/stats |
GET | Usage statistics |
/chat |
POST | Conversational chat endpoint |
/diagnose |
POST | Structured diagnosis |
/feedback |
POST | Submit user feedback |
/submit-correction |
POST | Submit new solutions |
/export/chat-history |
GET | Export chat logs |
/export/corrections |
GET | Export user contributions |
Ensure Ollama is running in the background. Open a terminal and run:
ollama serve- Verify CSV format matches expected columns
- Check for missing values in critical columns
- Ensure proper encoding (UTF-8)
Contributions are welcome! Here's how you can help:
- Report Issues: Found a bug? Open an issue
- Submit Solutions: Use the built-in correction form
- Code Improvements: Fork, improve, and submit PRs
- Documentation: Help improve this README
This project is licensed under the MIT License - see the LICENSE file for details.