fleetmind-dispatch-ai / DRIVER_CREATION_GUIDE.md
mashrur950's picture
Initial commit: FleetMind MCP with GitHub Actions auto-sync
d69447e
|
raw
history blame
7.49 kB
# Driver Creation Feature Guide
## βœ… **Feature Status: READY**
The driver creation feature has been successfully implemented and tested!
---
## πŸš€ **How to Use**
### **Step 1: Restart Your Application**
Since we updated Gemini's system prompt and tools, restart the app:
```bash
# Stop the current app (Ctrl+C)
python ui/app.py
```
---
### **Step 2: Create Drivers Using Natural Language**
Open the chat at http://127.0.0.1:7860 and type naturally!
---
## πŸ“ **Example Commands**
### **Example 1: Complete Driver Info**
```
Add new driver Tom Wilson, phone 555-0101, drives a van, plate ABC-123
```
**Gemini will create:**
- Driver ID: DRV-20251114HHMMSS (auto-generated)
- Name: Tom Wilson
- Phone: 555-0101
- Vehicle: van
- Plate: ABC-123
- Status: active (default)
- Capacity: 1000 kg (default for van)
---
### **Example 2: Driver with Skills**
```
Create driver Sarah Martinez, phone 555-0202, refrigerated truck, plate XYZ-789,
skills: medical_certified, refrigerated
```
**Gemini will create:**
- Name: Sarah Martinez
- Phone: 555-0202
- Vehicle: truck
- Plate: XYZ-789
- Skills: ["medical_certified", "refrigerated"]
- Capacity: 1000 kg (default)
---
### **Example 3: Minimal Info (Name Only)**
```
Add driver Mike Chen
```
**Gemini will create:**
- Name: Mike Chen
- Vehicle: van (default)
- Capacity: 1000 kg (default)
- Status: active (default)
- Skills: [] (empty by default)
Gemini might ask: "Would you like to provide phone number or vehicle details?"
---
### **Example 4: Motorcycle Courier**
```
New driver: Lisa Anderson, phone 555-0303, motorcycle, express delivery specialist
```
**Gemini will create:**
- Name: Lisa Anderson
- Phone: 555-0303
- Vehicle: motorcycle
- Skills: ["express_delivery"]
- Capacity: 50 kg (you can specify)
---
## 🎯 **Available Fields**
### **Required:**
- βœ… **name** - Driver's full name
### **Optional:**
- **phone** - Contact number (e.g., "+1-555-0101")
- **email** - Email address (e.g., "[email protected]")
- **vehicle_type** - van | truck | car | motorcycle (default: van)
- **vehicle_plate** - License plate (e.g., "ABC-1234")
- **capacity_kg** - Cargo weight capacity in kg (default: 1000.0)
- **capacity_m3** - Cargo volume capacity in mΒ³ (default: 12.0)
- **skills** - List of certifications/skills:
- `refrigerated` - Can handle cold storage
- `medical_certified` - Medical deliveries
- `fragile_handler` - Fragile items expert
- `overnight` - Overnight/late deliveries
- `express_delivery` - Express/rush deliveries
- **status** - active | busy | offline | unavailable (default: active)
---
## πŸ§ͺ **Testing**
### **Test 1: Verify Creation**
After creating a driver, check the database:
```bash
python verify_drivers.py
```
This will show all drivers including the newly created one.
---
### **Test 2: Check in UI**
Go to the **Orders** tab in the UI and you should see new drivers available for assignment.
---
## πŸ“Š **What Happens Behind the Scenes**
### **User Input:**
```
"Add new driver Tom Wilson, phone 555-0101, drives a van, plate ABC-123"
```
### **Gemini Processing:**
1. **Parses** your natural language input
2. **Extracts** driver information:
- name: "Tom Wilson"
- phone: "555-0101"
- vehicle_type: "van"
- vehicle_plate: "ABC-123"
3. **Calls** `create_driver` tool with extracted data
4. **Database** inserts the driver with auto-generated ID
5. **Returns** confirmation message
### **Database Record Created:**
```sql
INSERT INTO drivers (
driver_id, -- DRV-20251114113250 (auto)
name, -- Tom Wilson
phone, -- 555-0101
vehicle_type, -- van
vehicle_plate, -- ABC-123
status, -- active (default)
capacity_kg, -- 1000.0 (default)
capacity_m3, -- 12.0 (default)
skills, -- [] (empty)
current_lat, -- 37.7749 (default SF)
current_lng, -- -122.4194 (default SF)
last_location_update -- 2025-11-14 11:32:50
) VALUES (...)
```
---
## πŸ”„ **Comparison: Orders vs Drivers**
### **Creating an Order:**
```
User: "Create order for John Doe, 123 Main St SF, phone 555-1234"
↓
Gemini: [geocode_address] β†’ [create_order] β†’ "βœ… Order created!"
```
**2 tools called** (geocoding required for addresses)
### **Creating a Driver:**
```
User: "Add driver Tom Wilson, phone 555-0101, van"
↓
Gemini: [create_driver] β†’ "βœ… Driver created!"
```
**1 tool called** (no geocoding needed)
---
## ⚑ **Quick Reference**
### **Conversational Examples:**
βœ… "I need to onboard a new driver named Alex"
βœ… "Add Sarah to the fleet, she drives a truck"
βœ… "New driver: Mike, phone 555-9999, motorcycle"
βœ… "Create driver with medical certification"
βœ… "Add a refrigerated truck driver named Bob"
### **Structured Examples:**
βœ… "Create driver: Name: Tom Wilson, Phone: 555-0101, Vehicle: van, Plate: ABC-123"
βœ… "New driver - Name: Sarah, Email: [email protected], Vehicle type: truck, Skills: refrigerated, medical_certified"
---
## 🎨 **Sample Responses from Gemini**
### **Successful Creation:**
```
βœ… Driver DRV-20251114113250 created successfully!
Driver Details:
β€’ Driver ID: DRV-20251114113250
β€’ Name: Tom Wilson
β€’ Phone: 555-0101
β€’ Vehicle: van (ABC-123)
β€’ Capacity: 1000 kg
β€’ Status: Active
β€’ Skills: None
The driver has been added to your fleet and is ready for order assignments!
```
### **Missing Information:**
```
I can create a driver for you! I have:
β€’ Name: Tom Wilson
To complete the driver profile, please provide (optional):
β€’ Phone number
β€’ Vehicle type (van/truck/car/motorcycle)
β€’ License plate number
β€’ Any special skills or certifications
Or I can create the driver now with default settings?
```
---
## πŸ› οΈ **Technical Details**
### **Function:** `handle_create_driver()`
**Location:** `chat/tools.py:245-331`
### **Tool Definition:**
**Location:** `chat/providers/gemini_provider.py:140-186`
### **System Prompt:**
**Location:** `chat/providers/gemini_provider.py:32-89`
---
## ✨ **Next Steps**
After creating drivers, you can:
1. **Assign orders to drivers** (coming soon)
2. **View driver list** in the UI
3. **Update driver status** (active/busy/offline)
4. **Track driver locations** (coming soon)
---
## πŸ› **Troubleshooting**
### **Issue: "Unknown tool: create_driver"**
**Solution:** Restart the application to reload the new tools:
```bash
# Stop app (Ctrl+C)
python ui/app.py
```
### **Issue: Driver created but not showing in database**
**Solution:** Check database connection and verify:
```bash
python verify_drivers.py
```
### **Issue: "Missing required field: name"**
**Solution:** Make sure you provide at least the driver's name:
```
"Add driver John Smith" βœ…
"Add a new driver" ❌ (no name)
```
---
## πŸ“ˆ **Feature Comparison**
| Feature | Orders | Drivers |
|---------|--------|---------|
| **Required Fields** | 3 (name, address, contact) | 1 (name) |
| **Geocoding Needed** | βœ… Yes | ❌ No |
| **Tools Called** | 2 (geocode + create) | 1 (create) |
| **Default Values** | Priority, weight | Vehicle type, capacity, status |
| **Complex Data** | Time windows, coordinates | Skills array, JSON |
---
## πŸŽ‰ **Ready to Use!**
Your FleetMind system can now:
- βœ… Create customer orders
- βœ… Create delivery drivers
- βœ… Geocode addresses
- βœ… Store everything in PostgreSQL
Just talk naturally to Gemini and it handles the rest! πŸš€