Spaces:
Sleeping
A newer version of the Gradio SDK is available:
5.44.1
Network Infrastructure AI Assistant
This project implements an AI-powered network infrastructure assistant with specialized port recommendation capabilities using the OpenAI Agents SDK.
Architecture Overview
The system follows a modular architecture based on the OpenAI Agents SDK:
Core Components
retriever_tool.py
- Network information retrieval tool- Uses FAISS vector database for semantic search
- Searches through network documentation and device configurations
- Returns relevant network information with similarity scores
port_recommnedations.py
- Specialized port recommendations agent- Expert agent focused on port/interface recommendations
- Understands MLAG configurations and redundancy requirements
- Provides specific device names and port numbers
app.py
- Main orchestrator application- Combines retrieval tool and port recommendations agent
- Provides Gradio web interface
- Routes queries to appropriate tools based on context
port_recommendations_standalone.py
- Standalone port recommendations- Direct access to port recommendations agent
- Useful for testing and scripting
Key Features
Port Recommendations
- Automatic redundancy across MLAG pairs (leaf01/leaf02, leaf03/leaf04, etc.)
- Same port numbers across paired devices when possible
- Support for single port requests (without redundancy)
- Detailed responses with device names and specific port identifiers
Network Information Retrieval
- Semantic search through network documentation
- Device-specific configuration lookup
- Fabric-wide information queries
Usage Examples
Port Recommendations
# Various ways to request ports
"I need an unused port" # Returns 2 ports with redundancy
"I need an unused port without redundancy" # Returns 1 port
"I need to dual connect a server to the network" # Returns MLAG pair
"What ports are available on leaf01?" # Device-specific query
General Network Queries
"What is the BGP configuration?"
"Show me the VLAN settings"
"What's the loopback pool configuration?"
Running the System
Web Interface
python app.py
This launches a Gradio web interface where you can ask questions about the network infrastructure.
Standalone Port Recommendations
python port_recommendations_standalone.py
This runs a test suite with various port recommendation queries.
Testing Individual Components
from port_recommnedations import port_recommendations_agent
from retriever_tool import retrieve_network_information
# Test retrieval tool
result = retrieve_network_information("unused ports")
# Test port agent (requires async)
import asyncio
from agents import Runner
async def test():
result = await Runner.run(port_recommendations_agent, "I need a port")
print(result.final_output)
asyncio.run(test())
File Structure
agent-sdk/
βββ retriever_tool.py # Network information retrieval
βββ port_recommnedations.py # Specialized port agent
βββ app.py # Main orchestrator with Gradio UI
βββ port_recommendations_standalone.py # Standalone port recommendations
βββ faiss_index/ # Vector database
βββ prompts.yaml # Prompt templates
βββ README_AGENTS.md # This file
Dependencies
openai-agents
: OpenAI Agents SDKlangchain-community
: FAISS and embeddingssentence-transformers
: Text embeddingsgradio
: Web interfacePyYAML
: Configuration files
Agent Design Principles
Based on the OpenAI Agents SDK documentation:
- Function Tools: The retriever uses
@function_tool
decorator for automatic tool setup - Agents as Tools: Port recommendations agent is used as a tool in the main orchestrator
- Specialized Instructions: Each agent has domain-specific instructions and behaviors
- Tool Routing: Main agent routes queries to appropriate specialized tools
Port Recommendation Rules
The port recommendations agent follows these key rules:
- Default Redundancy: Always recommend two ports across different devices unless specifically requested otherwise
- MLAG Pairing: Recommend ports across MLAG pairs (odd/even leaf switches)
- Port Alignment: Try to use the same port number across paired devices
- Specific Responses: Include device names and exact port identifiers
- Query First: Will return only data from the leaf switches
Future Enhancements
- Add more specialized agents (security policies, VLAN management, etc.)
- Implement caching for frequently requested information
- Add support for configuration changes and validation
- Integrate with network management systems