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:
# 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 storagemedical_certified- Medical deliveriesfragile_handler- Fragile items expertovernight- Overnight/late deliveriesexpress_delivery- Express/rush deliveries
- status - active | busy | offline | unavailable (default: active)
π§ͺ Testing
Test 1: Verify Creation
After creating a driver, check the database:
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:
- Parses your natural language input
- Extracts driver information:
- name: "Tom Wilson"
- phone: "555-0101"
- vehicle_type: "van"
- vehicle_plate: "ABC-123"
- Calls
create_drivertool with extracted data - Database inserts the driver with auto-generated ID
- Returns confirmation message
Database Record Created:
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:
- Assign orders to drivers (coming soon)
- View driver list in the UI
- Update driver status (active/busy/offline)
- Track driver locations (coming soon)
π Troubleshooting
Issue: "Unknown tool: create_driver"
Solution: Restart the application to reload the new tools:
# Stop app (Ctrl+C)
python ui/app.py
Issue: Driver created but not showing in database
Solution: Check database connection and verify:
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! π