Coding
PromptBeginner5 minmarkdown
Nano Banana Pro
Agent skill for nano-banana-pro
7
cd /Users/moshesmanihuruk/Downloads/PSANEW/psa/HACKATHON_SOLUTION
Sign in to like and favorite skills
cd /Users/moshesmanihuruk/Downloads/PSANEW/psa/HACKATHON_SOLUTION pip install -r requirements_agents.txt
Edit
config/db_config.json:
{ "host": "localhost", "user": "root", "password": "your_password", "database": "appdb" }
cd python python agent_kb_search.py
Output:
π Initializing KnowledgeBaseAgent... Building FAISS index from Knowledge Base... Extracted 313 KB entries Generating embeddings... β FAISS index built with 313 vectors πΎ Index saved to kb_faiss.index
python orchestrator_langgraph.py
Expected output:
π€ INITIALIZING MULTI-AGENT ORCHESTRATOR ====================================================================== π Initializing KnowledgeBaseAgent... β Loaded 313 KB entries π Initializing HistoricalIncidentAgent... β Connected to database: appdb π Initializing LogsSearchAgent... β Connected to database: appdb β Orchestrator initialized π PROCESSING INCIDENT THROUGH MULTI-AGENT SYSTEM ====================================================================== STEP 1: Knowledge Base Search ====================================================================== π KnowledgeBaseAgent - Searching Knowledge Base β Found 3 relevant KB articles Best Match: EDI Timeout Issues Similarity: 85% STEP 2: Historical Incident Search ====================================================================== π HistoricalIncidentAgent - Searching Historical Data β Found 5 similar incidents Average Resolution Time: 18.5 minutes STEP 3: Logs Analysis ====================================================================== π LogsSearchAgent - Analyzing Recent Logs β Found 12 recent changes Critical Changes: 3 STEP 4: Decision Making ====================================================================== π CONFIDENCE SCORES: KB Agent: 85% Historical Agent: 72% Logs Agent: 65% Combined: 76% π― FINAL DECISION: RESOLVE β Resolution Steps: 5 β Verification Steps: 3
from Source_Parser import EmailParser from orchestrator_langgraph import IncidentResolutionOrchestrator # Parse alert parser = EmailParser() alert = """ Subject: URGENT - COARRI Timeout COARRI EDI message for vessel MSC GEMMA failed with timeout. """ parsed = parser.parse_email(alert) # Run agents orchestrator = IncidentResolutionOrchestrator() result = orchestrator.process_incident(parsed) # Get recommendation print(f"Decision: {result['decision']}") print(f"Steps: {len(result['resolution']['steps'])}") orchestrator.close()
from agent_kb_search import KnowledgeBaseAgent agent = KnowledgeBaseAgent() incident = { 'problem_statement': 'BAPLIE position mismatch detected', 'module': 'Vessel Operations' } result = agent.execute(incident) print(f"Confidence: {result['confidence']:.1%}") print(f"Steps: {result['resolution_steps']}")
from orchestrator_langgraph import IncidentResolutionOrchestrator orchestrator = IncidentResolutionOrchestrator() # Override decision threshold def custom_decision(state): if state['combined_confidence'] > 0.9: return "RESOLVE" return "ESCALATE" # Process with custom logic result = orchestrator.process_incident(parsed_incident)
Alert/Email β Parser (Objective) β Orchestrator β βββββββββββββ¬ββββββββββββ¬ββββββββββββ β KB β Historicalβ Logs β β Agent β Agent β Agent β βββββββ¬ββββββ΄ββββββ¬ββββββ΄ββββββ¬ββββββ βββββββββββββ΄ββββββββββββ β Decision Engine β ββββββββ΄βββββββ β β RESOLVE ESCALATE
{ "decision": "RESOLVE", "combined_confidence": 0.85, "resolution": { "steps": ["Step 1", "Step 2", "..."], "verification": ["Check 1", "Check 2"], "root_cause": "Connection pool exhausted" } }
Action: Execute resolution steps, verify, mark resolved
{ "decision": "ESCALATE", "combined_confidence": 0.35, "escalation": { "required": true, "reason": "Novel incident, requires expert analysis" } }
Action: Create escalation ticket, notify product team
In
orchestrator_langgraph.py:
combined_confidence = ( kb_confidence * 0.4 + # Change to 0.5 for more KB weight historical_confidence * 0.4 + # Change to 0.3 logs_confidence * 0.2 # Keep at 0.2 )
# In _make_decision() method if severity == 'CRITICAL' and combined_confidence < 0.8: # Change to 0.9 decision = "ESCALATE"
# agent_custom.py class CustomAgent: def execute(self, parsed_incident): # Your logic return {'confidence': 0.8, 'result': '...'}
# In orchestrator_langgraph.py self.custom_agent = CustomAgent() # Add node workflow.add_node("custom_search", self._execute_custom_agent) workflow.add_edge("logs_search", "custom_search")
| Issue | Solution |
|---|---|
| ImportError: faiss | |
| Database connection failed | Check credentials |
| No KB entries | Run first |
| LangGraph not found | |
| Low confidence scores | Rebuild FAISS index, check KB data |
| Score | Meaning | Action |
|---|---|---|
| 90-100% | Exact match found | Auto-resolve |
| 70-89% | Strong match | Resolve with monitoring |
| 50-69% | Moderate match | Resolve cautiously |
| 30-49% | Weak match | Escalate (novel case) |
| 0-29% | No match | Escalate immediately |
result['decision'] == 'RESOLVE' and result['combined_confidence'] > 0.8 # β Green: High confidence resolution result['decision'] == 'RESOLVE' and result['combined_confidence'] < 0.7 # β οΈ Yellow: Cautious resolution, monitor closely result['decision'] == 'ESCALATE' # π΄ Red: Escalation required
category, status, reported_at# In Django view from orchestrator_langgraph import IncidentResolutionOrchestrator def handle_incident(request): alert_text = request.POST['alert'] parsed = parser.parse_email(alert_text) result = orchestrator.process_incident(parsed) if result['decision'] == 'RESOLVE': # Create ticket with resolution steps Ticket.objects.create( status='IN_PROGRESS', resolution_steps=result['resolution']['steps'] ) else: # Escalate Escalation.objects.create( reason=result['escalation']['reason'] )
# WebSocket update result = orchestrator.process_incident(parsed) websocket.send({ 'type': 'incident_analyzed', 'decision': result['decision'], 'confidence': result['combined_confidence'], 'steps': result['resolution']['steps'] })
# Test parser only python Source_Parser.py # Test KB agent python agent_kb_search.py # Test historical agent python agent_historical_search.py # Test logs agent python agent_logs_search.py # Test full orchestrator python orchestrator_langgraph.py # Rebuild FAISS index python -c "from agent_kb_search import KnowledgeBaseAgent; KnowledgeBaseAgent().rebuild_index()"
Ready to start? Run
python orchestrator_langgraph.py π