File size: 7,623 Bytes
fc9ae06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Overgrowth Pipeline Enhancement Plan

## What's Missing (Your Feedback Summary)

1. **❌ No Interactive Consultation** - Should ask follow-up questions
2. **❌ Source of Truth Incomplete** - No subnets, VLANs, real design
3. **❌ BOM Pricing Wrong** - Shows $0 for everything
4. **❌ Setup Guide Generic** - Missing firmware updates, real steps
5. **❌ No Progress Visibility** - Can't see what AI agents are doing
6. **❌ No Network Simulation Link** - Should show GNS3 topology

## Implementation Plan

### Phase 1: LLM Integration (PRIORITY)

**Files Created:**
- `agent/llm_client.py` - Unified LLM client (OpenAI/Anthropic/OpenRouter)
- `agent/consultation.py` - Interactive multi-turn consultation

**Setup Required:**

```bash
# Add to .env file:
OPENROUTER_API_KEY=sk-or-v1-xxxxx  # From your hackathon credits
# OR
OPENAI_API_KEY=sk-xxxxx
# OR
ANTHROPIC_API_KEY=sk-ant-xxxxx
```

**Testing:**
```python
from agent.consultation import NetworkConsultant

consultant = NetworkConsultant()
is_complete, output, intent = consultant.start_consultation(
    "We're a coffee shop chain with 3 locations..."
)
print(output)  # Will show follow-up questions

# User answers questions
is_complete, output, intent = consultant.continue_consultation(
    "Budget is $50k, need it in 3 months, prefer Ubiquiti gear"
)
```

### Phase 2: Smart Network Design

**Enhance `stage2_generate_sot()` in pipeline_engine.py:**

```python
def stage2_generate_sot(self, intent: NetworkIntent) -> NetworkModel:
    """Use LLM to design actual network architecture"""
    
    prompt = f"""
    Design a production-ready network for:
    {intent.description}
    
    Requirements:
    - Budget: {intent.budget}
    - Locations: {intent.locations}
    - Compliance: {intent.compliance_requirements}
    
    Generate:
    1. VLAN scheme (management, data, voice, guest, security cameras, POS)
    2. IP subnetting plan (RFC1918 private addressing)
    3. Device list (switches, APs, routers, firewalls)
    4. Routing protocol (static, OSPF, BGP)
    5. Security policies
    
    Return as structured JSON.
    """
    
    # Call LLM to generate real design
    design = llm.chat([LLMMessage(role="user", content=prompt)])
    
    # Parse into NetworkModel
    return self._parse_network_design(design)
```

**Example Output:**
```yaml
vlans:
  - id: 10
    name: Management
    subnet: 10.0.10.0/24
  - id: 20
    name: Guest_WiFi
    subnet: 10.0.20.0/24
  - id: 30
    name: POS_Systems
    subnet: 10.0.30.0/24
  - id: 40
    name: Security_Cameras
    subnet: 10.0.40.0/24

devices:
  - name: HQ-Core-SW01
    role: core
    model: Ubiquiti USW-Enterprise-48-PoE
    mgmt_ip: 10.0.10.10
    interfaces:
      - name: eth0/1
        vlan: 10
        mode: access
```

### Phase 3: Real BOM Pricing

**Create `agent/hardware_pricing.py`:**

```python
# Hardware database with real prices
HARDWARE_DB = {
    "Ubiquiti USW-Enterprise-48-PoE": {
        "price": 1799.00,
        "category": "switch",
        "vendor": "Ubiquiti"
    },
    "Ubiquiti U6-Enterprise": {
        "price": 379.00,
        "category": "access_point"
    },
    # ... more devices
}

def calculate_bom_cost(devices: List[Device]) -> float:
    total = 0
    for device in devices:
        if device.model in HARDWARE_DB:
            total += HARDWARE_DB[device.model]["price"]
    return total
```

### Phase 4: Streaming Progress Updates

**Modify `app.py` to use Gradio streaming:**

```python
def run_pipeline_streaming(user_input):
    """Stream progress updates to UI"""
    pipeline = OvergrowthPipeline()
    
    # Stage 1: Consultation
    yield "🤝 Stage 1: Starting consultation...\n"
    consultant = NetworkConsultant()
    is_complete, output, intent = consultant.start_consultation(user_input)
    
    if not is_complete:
        yield f"❓ **Follow-up questions:**\n{output}\n\n"
        # Wait for user response (need UI update for this)
        return
    
    yield f"✅ Stage 1 Complete\n{output}\n\n"
    
    # Stage 2: Generate SoT
    yield "📋 Stage 2: Designing network architecture...\n"
    model = pipeline.stage2_generate_sot(intent)
    yield f"✅ Stage 2 Complete - {len(model.devices)} devices, {len(model.vlans)} VLANs\n\n"
    
    # Stage 3: Diagrams
    yield "📊 Stage 3: Generating topology diagrams...\n"
    diagrams = pipeline.stage3_generate_diagrams(model)
    yield f"✅ Stage 3 Complete\n\n"
    
    # Continue with other stages...
```

**Update Gradio interface:**
```python
run_pipeline_btn.click(
    fn=run_pipeline_streaming,
    inputs=[pipeline_input],
    outputs=[pipeline_status],  # Single streaming output
    show_progress=True
)
```

### Phase 5: GNS3 Simulation Integration

**Add to pipeline results:**

```python
def stage6_autonomous_deploy(self, model: NetworkModel) -> Dict:
    """Deploy to GNS3 lab"""
    from agent.local_mcp import call_tool
    
    # Build topology in GNS3
    result = call_tool("create_project", {
        "name": model.name,
        "auto_start": True
    })
    
    project_id = result['project_id']
    
    # Add devices
    for device in model.devices:
        call_tool("add_node", {
            "project_id": project_id,
            "name": device.name,
            "node_type": device.role,
            "x": ...,  # Calculate layout
            "y": ...
        })
    
    # Return simulation URL
    return {
        "success": True,
        "gns3_url": f"http://lab.grahampaasch.com:3080/#/projects/{project_id}",
        "topology_link": f"View live simulation: {gns3_url}"
    }
```

**Display in UI:**
```markdown
## 🌐 Live Network Simulation

Your network is being built in GNS3:
- **Project:** {model.name}
- **Devices:** {len(model.devices)} nodes
- **Status:** Deploying...

[View in GNS3](http://lab.grahampaasch.com:3080/#/projects/{project_id})
```

### Phase 6: Setup Guide with Real Steps

**Enhance `stage5_setup_guide()`:**

```python
def generate_setup_guide(self, model: NetworkModel) -> SetupGuide:
    """Generate detailed deployment guide"""
    
    phases = [
        {
            "name": "Pre-Deployment Validation",
            "duration": "1 hour",
            "steps": [
                "Verify all equipment received matches BOM",
                "Check firmware versions - minimum required:",
                *[f"  - {d.model}: firmware v{get_min_firmware(d.model)}" 
                  for d in model.devices],
                "Unbox and inventory all equipment",
                "Download latest firmware if upgrades needed"
            ]
        },
        {
            "name": "Firmware Updates",
            "duration": "2-4 hours",
            "steps": [
                "Backup factory configs",
                "Update devices one at a time",
                *[f"Update {d.name} to {get_latest_firmware(d.model)}" 
                  for d in model.devices],
                "Verify boot-up and basic connectivity",
                "Document firmware versions"
            ]
        },
        # ... more realistic phases
    ]
    
    return SetupGuide(
        network_name=model.name,
        phases=phases,
        # ... other details
    )
```

## Next Steps

1. **Add LLM API key to .env**
2. **Test consultation flow**
3. **Enhance pipeline stages with LLM calls**
4. **Add hardware pricing database**
5. **Implement streaming UI updates**
6. **Wire up GNS3 deployment**

## Cost Estimate

Using OpenRouter with Claude 3.5 Sonnet:
- Consultation: ~$0.02 per session
- Network Design: ~$0.05 per design
- Total per pipeline run: ~$0.10

Your hackathon credits should cover hundreds of runs.