petter2025 commited on
Commit
74e4f46
·
verified ·
1 Parent(s): d352122

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -82
app.py CHANGED
@@ -1544,88 +1544,6 @@ class EnhancedReliabilityEngine:
1544
 
1545
  return result
1546
 
1547
- async def enhance_with_claude(
1548
- self,
1549
- event: ReliabilityEvent,
1550
- agent_results: Dict[str, Any]
1551
- ) -> Dict[str, Any]:
1552
- """
1553
- Enhance agent results with Claude AI reasoning
1554
-
1555
- This is a NON-INVASIVE layer - all existing logic stays intact.
1556
- If Claude fails, original results are returned unchanged.
1557
- """
1558
- try:
1559
- # Build comprehensive context for Claude
1560
- context_parts = []
1561
-
1562
- # Add event summary
1563
- context_parts.append("INCIDENT SUMMARY:")
1564
- context_parts.append(f"Component: {event.component}")
1565
- context_parts.append(f"Timestamp: {event.timestamp.isoformat()}")
1566
- context_parts.append(f"Severity: {event.severity.value}")
1567
- context_parts.append("")
1568
-
1569
- # Add metrics
1570
- context_parts.append("METRICS:")
1571
- context_parts.append(f"• Latency P99: {event.latency_p99}ms")
1572
- context_parts.append(f"• Error Rate: {event.error_rate:.1%}")
1573
- context_parts.append(f"• Throughput: {event.throughput} req/s")
1574
- if event.cpu_util:
1575
- context_parts.append(f"• CPU: {event.cpu_util:.1%}")
1576
- if event.memory_util:
1577
- context_parts.append(f"• Memory: {event.memory_util:.1%}")
1578
- context_parts.append("")
1579
-
1580
- # Add agent findings
1581
- if agent_results:
1582
- context_parts.append("AGENT ANALYSIS:")
1583
- if 'multi_agent_analysis' in agent_results:
1584
- analysis = agent_results['multi_agent_analysis']
1585
- context_parts.append(json.dumps(analysis, indent=2))
1586
- elif 'incident_summary' in agent_results:
1587
- context_parts.append(json.dumps(agent_results['incident_summary'], indent=2))
1588
-
1589
- context = "\n".join(context_parts)
1590
-
1591
- # Create prompt for Claude
1592
- prompt = f"""{context}
1593
-
1594
- TASK: Provide an executive summary synthesizing all agent analyses.
1595
- Include:
1596
- 1. Concise incident description
1597
- 2. Most likely root cause
1598
- 3. Single best recovery action
1599
- 4. Estimated impact and recovery time
1600
-
1601
- Be specific and actionable."""
1602
-
1603
- system_prompt = """You are a senior Site Reliability Engineer synthesizing
1604
- multiple AI agent analyses into clear, actionable guidance for incident response.
1605
- Focus on clarity, accuracy, and decisive recommendations."""
1606
-
1607
- # Get Claude's synthesis
1608
- logger.info("Requesting Claude synthesis of agent results")
1609
- claude_synthesis = claude_adapter.generate_completion(
1610
- prompt=prompt,
1611
- system_prompt=system_prompt
1612
- )
1613
-
1614
- # Add Claude's insights to results (non-destructive)
1615
- agent_results['claude_synthesis'] = {
1616
- 'summary': claude_synthesis,
1617
- 'timestamp': datetime.datetime.now(datetime.timezone.utc).isoformat(),
1618
- 'source': 'claude-opus-4'
1619
- }
1620
-
1621
- logger.info("✅ Claude synthesis added to results")
1622
- return agent_results
1623
-
1624
- except Exception as e:
1625
- logger.error(f"Claude enhancement failed: {e}", exc_info=True)
1626
- # Return original results unchanged - system still works!
1627
- return agent_results
1628
-
1629
  # === Initialize Engine (with dependency injection) ===
1630
  enhanced_engine = EnhancedReliabilityEngine()
1631
 
 
1544
 
1545
  return result
1546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1547
  # === Initialize Engine (with dependency injection) ===
1548
  enhanced_engine = EnhancedReliabilityEngine()
1549