File size: 7,486 Bytes
d69447e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# 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! π
|