{"id":40709744,"url":"https://github.com/bayars/router-config-rag","last_synced_at":"2026-01-21T12:39:36.103Z","repository":{"id":331303275,"uuid":"1126104829","full_name":"bayars/router-config-rag","owner":"bayars","description":"A fully local RAG (Retrieval Augmented Generation) agent that helps configure Nokia SR Linux/SROS/SR-SIM routers using official documentations.","archived":false,"fork":false,"pushed_at":"2026-01-01T05:45:55.000Z","size":23894,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-06T00:14:17.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bayars.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-01T05:41:43.000Z","updated_at":"2026-01-01T05:45:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bayars/router-config-rag","commit_stats":null,"previous_names":["bayars/router-config-rag"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/bayars/router-config-rag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayars%2Frouter-config-rag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayars%2Frouter-config-rag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayars%2Frouter-config-rag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayars%2Frouter-config-rag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bayars","download_url":"https://codeload.github.com/bayars/router-config-rag/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bayars%2Frouter-config-rag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28632981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-21T12:39:36.048Z","updated_at":"2026-01-21T12:39:36.098Z","avatar_url":"https://github.com/bayars.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nokia SR Linux Router Configuration Agent\n\nA fully local RAG (Retrieval Augmented Generation) agent that helps configure Nokia SR Linux routers using official documentation. Runs 100% locally with Ollama - no cloud APIs or API keys required.\n\n## Features\n\n- **100% Local**: Runs entirely on your machine using Ollama\n- **RAG Pipeline**: Semantic search over SR Linux documentation\n- **Multi-Router Config Generation**: Generate configs for multiple routers at once\n- **Interactive Chat**: Natural language interface with conversation history\n- **Web Scraping**: Can ingest documentation from websites\n- **Persistent Knowledge Base**: ChromaDB vector store\n\n## Architecture Overview\n\n```\n┌─────────────────────────────────────────────────────────────────────────────┐\n│                        USER INTERACTION LAYER                               │\n│  ┌─────────────┐                                                            │\n│  │   main.py   │  Interactive CLI / Commands: stats, reset, quit           │\n│  └──────┬──────┘                                                            │\n└─────────┼───────────────────────────────────────────────────────────────────┘\n          │\n          ▼\n┌─────────────────────────────────────────────────────────────────────────────┐\n│                           RAG AGENT LAYER                                   │\n│  ┌──────────────────────────────────────────────────────────────────────┐   │\n│  │                     router_agent.py                                   │   │\n│  │  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐   │   │\n│  │  │  Query Analysis │───▶│ Context Builder │───▶│  LLM Generation │   │   │\n│  │  │  (intent detect)│    │  (top-k chunks) │    │   (via Ollama)  │   │   │\n│  │  └─────────────────┘    └─────────────────┘    └─────────────────┘   │   │\n│  │           │                                              │            │   │\n│  │           │         ┌─────────────────────┐              │            │   │\n│  │           └────────▶│ Config File Writer  │◀─────────────┘            │   │\n│  │                     │  (multi-router .cfg)│                           │   │\n│  │                     └─────────────────────┘                           │   │\n│  └──────────────────────────────────────────────────────────────────────┘   │\n└─────────────────────────────────────────────────────────────────────────────┘\n          │\n          ▼\n┌─────────────────────────────────────────────────────────────────────────────┐\n│                         KNOWLEDGE BASE LAYER                                │\n│                                                                             │\n│  ┌─────────────────┐         ┌─────────────────┐         ┌──────────────┐  │\n│  │ vector_store.py │◀───────▶│    ChromaDB     │◀───────▶│   Ollama     │  │\n│  │                 │         │  (chroma_db/)   │         │  Embeddings  │  │\n│  │  - add_documents│         │                 │         │              │  │\n│  │  - search       │         │  Persisted      │         │ nomic-embed  │  │\n│  │  - clear        │         │  Vectors        │         │    -text     │  │\n│  └─────────────────┘         └─────────────────┘         └──────────────┘  │\n│                                                                             │\n└─────────────────────────────────────────────────────────────────────────────┘\n          ▲\n          │\n┌─────────────────────────────────────────────────────────────────────────────┐\n│                       DOCUMENT PROCESSING LAYER                             │\n│                                                                             │\n│  ┌─────────────────┐                           ┌─────────────────┐          │\n│  │ pdf_processor.py│                           │ web_scraper.py  │          │\n│  │                 │                           │                 │          │\n│  │  PDF ──▶ Text   │                           │  URL ──▶ Text   │          │\n│  │  Text ──▶ Chunks│                           │  HTML ──▶ Chunks│          │\n│  │                 │                           │                 │          │\n│  │  1000 chars/chunk                           │  BeautifulSoup  │          │\n│  │  200 char overlap                           │  Nav removal    │          │\n│  └────────┬────────┘                           └────────┬────────┘          │\n│           │                                             │                   │\n│           ▼                                             ▼                   │\n│  ┌─────────────────────────────────────────────────────────────────────┐   │\n│  │                         docs/ Directory                              │   │\n│  │   srlinux.pdf, sros.pdf, routing_protocols_guide.pdf, etc.          │   │\n│  └─────────────────────────────────────────────────────────────────────┘   │\n└─────────────────────────────────────────────────────────────────────────────┘\n```\n\n## RAG Pipeline Flow\n\n```\n┌──────────┐    ┌───────────────┐    ┌─────────────┐    ┌──────────────┐\n│  User    │    │   Embedding   │    │   Vector    │    │   Top-K      │\n│  Query   │───▶│   (Ollama)    │───▶│   Search    │───▶│   Chunks     │\n└──────────┘    └───────────────┘    └─────────────┘    └──────┬───────┘\n                                                               │\n                                                               ▼\n┌──────────┐    ┌───────────────┐    ┌─────────────┐    ┌──────────────┐\n│ Response │◀───│  LLM (Ollama) │◀───│   Prompt    │◀───│   Context    │\n│          │    │               │    │  + Context  │    │   Building   │\n└──────────┘    └───────────────┘    └─────────────┘    └──────────────┘\n```\n\n## Video Presentation\n\n![Video](./docs/nomic.mp4)\n\n\u003cvideo src=\"https://github.com/bayars/router-config-rag/blob/main/docs/nomic.mp4\" controls\u003e\u003c/video\u003e\n\n## Quick Start\n\n### Prerequisites\n\n- Python 3.8+\n- [Ollama](https://ollama.ai/) installed and running\n- 4GB+ RAM (8GB+ recommended)\n\n### Installation\n\n```bash\n# 1. Clone and enter directory\ncd nokia-srlinux-agent\n\n# 2. Create virtual environment\npython -m venv .venv\nsource .venv/bin/activate  # Linux/Mac\n# .venv\\Scripts\\activate   # Windows\n\n# 3. Install dependencies\npip install -r requirements.txt\n\n# 4. Start Ollama\nollama serve\n\n# 5. Pull required models (in another terminal)\nollama pull nomic-embed-text   # Embedding model (required)\nollama pull llama3.2           # Default LLM\n```\n\n### Download Documentation\n\nPlace Nokia SR Linux PDFs in the `docs/` directory:\n\n```bash\nmkdir -p docs\n# Download PDFs from Nokia documentation portal\n# See docs section below for download links\n```\n\n### Run the Agent\n\n```bash\n# First run (builds vector database)\npython main.py\n\n# Force rebuild after adding new documents\npython main.py --rebuild\n```\n\n## LLM Model Selection\n\n### Model Comparison\n\n| Model | Parameters | RAM Required | Speed | Quality | Best For |\n|-------|------------|--------------|-------|---------|----------|\n| `tinyllama` | 1.1B | 2-4 GB | Fastest | Basic | Testing, low-end hardware |\n| `phi3:mini` | 3.8B | 4-6 GB | Fast | Good | Edge devices, quick responses |\n| `gemma2:2b` | 2B | 4-6 GB | Fast | Good | Balanced performance |\n| `llama3.2` | 3B | 6-8 GB | Fast | Good | **Default - recommended** |\n| `mistral` | 7B | 8-12 GB | Medium | Better | General use |\n| `llama3.1:8b` | 8B | 10-16 GB | Medium | Better | Multi-router configs |\n| `gemma2:9b` | 9B | 12-16 GB | Medium | Better | Complex configs |\n| `llama3.1:70b` | 70B | 48+ GB | Slow | Best | Maximum accuracy |\n\n### Using Different Models\n\n```bash\n# Environment variable\nexport LLM_MODEL=\"tinyllama\"\npython main.py\n\n# Or inline\nLLM_MODEL=\"phi3:mini\" python main.py\n\n# For multi-router generation (need larger models)\nLLM_MODEL=\"llama3.1:8b\" python main.py\n```\n\n### Smallest Models for Low-End Hardware\n\n```bash\n# Absolute minimum (1.1B params, ~2GB RAM)\nollama pull tinyllama\nLLM_MODEL=\"tinyllama\" python main.py\n\n# Good balance for low memory (3.8B params, ~4GB RAM)\nollama pull phi3:mini\nLLM_MODEL=\"phi3:mini\" python main.py\n\n# Google's compact model (2B params)\nollama pull gemma2:2b\nLLM_MODEL=\"gemma2:2b\" python main.py\n```\n\n## Usage\n\n### Interactive Commands\n\n| Command | Description |\n|---------|-------------|\n| `stats` | Show knowledge base statistics |\n| `reset` | Clear conversation history |\n| `quit` / `exit` / `q` | Exit the agent |\n\n### Example Session\n\n```\n$ python main.py\n\nSR Linux Router Configuration Agent\n============================================================\nI can help you configure Nokia SR Linux routers!\n\nYou: How do I configure a BGP neighbor?\n\nAgent: To configure a BGP neighbor on SR Linux, use the following commands:\n\n    enter candidate\n\n    /network-instance default {\n        protocols {\n            bgp {\n                autonomous-system 65001\n                router-id 10.0.0.1\n                neighbor 10.0.0.2 {\n                    peer-as 65002\n                    peer-group ebgp-peers\n                }\n            }\n        }\n    }\n\n    commit now\n\nYou: write configs for 3 routers with OSPF\n\nAgent: I'll generate configurations for 3 routers...\n[Writes router1.cfg, router2.cfg, router3.cfg to configs/]\n```\n\n## Documentation Sources\n\n### Included PDFs (download to `docs/`)\n\n| Document | Description | Download |\n|----------|-------------|----------|\n| `srlinux.pdf` | SR Linux base documentation | Nokia portal |\n| `sros.pdf` | Service Router OS documentation | Nokia portal |\n| `config_basics_guide_24.7.pdf` | Configuration basics | [Link](https://documentation.nokia.com/srlinux/24-7/books/pdf/Configuration_Basics_Guide_24.7.pdf) |\n| `routing_protocols_guide.pdf` | BGP, OSPF, IS-IS | [Link](https://documentation.nokia.com/srlinux/23-3/books/pdf/Routing-Protocols-Guide_23.3.pdf) |\n| `interface_config_guide.pdf` | Interface configuration | Nokia portal |\n| `system_mgmt_guide_24.7.pdf` | CLI, gNMI, JSON-RPC | [Link](https://documentation.nokia.com/srlinux/24-7/books/pdf/System_Management_Guide_24.7.pdf) |\n| `vpn_services_guide_25.7.pdf` | EVPN, MPLS, VPN | [Link](https://documentation.nokia.com/srlinux/25-7/books/pdf/VPN_Services_Guide_25.7.pdf) |\n\n### Adding New Sources\n\nEdit `main.py` to add PDFs or websites:\n\n```python\nPDF_PATHS = [\n    \"docs/srlinux.pdf\",\n    \"docs/your_new_doc.pdf\",  # Add new PDF\n]\n\nWEB_URLS = [\n    \"https://documentation.nokia.com/srlinux/24-7/\",  # Add website\n]\n```\n\nThen rebuild: `python main.py --rebuild`\n\n## Project Structure\n\n```\n.\n├── main.py                 # CLI entry point\n├── router_agent.py         # RAG agent implementation\n├── vector_store.py         # ChromaDB + Ollama embeddings\n├── pdf_processor.py        # PDF text extraction/chunking\n├── web_scraper.py          # Website scraping\n├── requirements.txt        # Python dependencies\n├── tests/                  # Test scripts\n│   ├── test_agent.py\n│   ├── test_write_configs.py\n│   ├── test_12_routers.py\n│   └── test_parsing.py\n├── docs/                   # PDF documentation (gitignored)\n├── examples/               # Example prompts and outputs\n├── configs/                # Generated .cfg files (gitignored)\n└── chroma_db/              # Vector database (gitignored)\n```\n\n## Technology Stack\n\n| Component | Technology |\n|-----------|------------|\n| LLM Inference | [Ollama](https://ollama.ai/) |\n| Embeddings | nomic-embed-text via Ollama |\n| Vector Database | [ChromaDB](https://www.trychroma.com/) |\n| PDF Processing | pypdf |\n| Web Scraping | BeautifulSoup4 |\n\n## Troubleshooting\n\n### Connection Errors\n\n```bash\n# Ensure Ollama is running\nollama serve\n\n# Check Ollama status\ncurl http://localhost:11434/api/tags\n```\n\n### Model Not Found\n\n```bash\n# List installed models\nollama list\n\n# Pull missing models\nollama pull nomic-embed-text\nollama pull llama3.2\n```\n\n### Out of Memory\n\n```bash\n# Use a smaller model\nLLM_MODEL=\"tinyllama\" python main.py\n\n# Or use quantized versions\nollama pull llama3.2:1b-q4_0\n```\n\n### Slow Performance\n\n- Use smaller models (tinyllama, phi3:mini)\n- Reduce chunk retrieval: edit `router_agent.py` to lower `top_k`\n- Ensure you're using GPU acceleration if available\n\n## License\n\nMIT License - See LICENSE file for details.\n\n## Resources\n\n- [Nokia SR Linux Documentation](https://documentation.nokia.com/srlinux/)\n- [Learn SR Linux](https://learn.srlinux.dev/)\n- [Ollama](https://ollama.ai/)\n- [ChromaDB](https://www.trychroma.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbayars%2Frouter-config-rag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbayars%2Frouter-config-rag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbayars%2Frouter-config-rag/lists"}