Router Config RAG: Local AI Agent for Nokia SR Linux/SROS
Router Config RAG: Local AI Agent for Nokia SR Linux/SROS
router-config-rag is a fully local Retrieval-Augmented Generation (RAG) agent that helps configure Nokia SR Linux, SROS, and SR-SIM routers by answering questions directly from the official documentation — no cloud, no API keys.
Why This Project
Nokia’s SR Linux and SROS have extensive, complex documentation. Finding the right CLI command or config snippet often means diving through hundreds of pages of manuals. This project indexes those docs locally and lets you query them in natural language.
Architecture
User Query
│
▼
┌─────────────────┐
│ Query Encoder │ (local embedding model)
└────────┬────────┘
│ vector similarity search
▼
┌─────────────────┐
│ Vector Store │ (FAISS / Chroma — local)
│ Nokia Docs │
└────────┬────────┘
│ top-k chunks
▼
┌─────────────────┐
│ Local LLM │ (Ollama / llama.cpp)
│ + Context │
└────────┬────────┘
│
▼
Answer with source referencesDocument Ingestion
The ingestion pipeline processes Nokia’s official documentation (PDF/HTML) into searchable vector embeddings.
from langchain.document_loaders import PyPDFLoader, DirectoryLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.vectorstores import Chroma
def ingest_docs(docs_path: str, persist_dir: str):
loader = DirectoryLoader(docs_path, glob="**/*.pdf", loader_cls=PyPDFLoader)
documents = loader.load()
splitter = RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200,
separators=["\n\n", "\n", " "]
)
chunks = splitter.split_documents(documents)
embeddings = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-MiniLM-L6-v2"
)
vectorstore = Chroma.from_documents(
documents=chunks,
embedding=embeddings,
persist_directory=persist_dir
)
vectorstore.persist()
print(f"Ingested {len(chunks)} chunks from {len(documents)} documents")RAG Query Pipeline
from langchain.llms import Ollama
from langchain.chains import RetrievalQA
from langchain.prompts import PromptTemplate
PROMPT_TEMPLATE = """You are an expert Nokia SR Linux/SROS network engineer.
Use the following documentation excerpts to answer the question accurately.
If the answer is not in the provided context, say so clearly.
Context:
{context}
Question: {question}
Answer (include relevant CLI commands or config snippets where applicable):"""
def build_qa_chain(persist_dir: str):
embeddings = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-MiniLM-L6-v2"
)
vectorstore = Chroma(
persist_directory=persist_dir,
embedding_function=embeddings
)
llm = Ollama(model="mistral", temperature=0)
prompt = PromptTemplate(
template=PROMPT_TEMPLATE,
input_variables=["context", "question"]
)
return RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=vectorstore.as_retriever(search_kwargs={"k": 5}),
chain_type_kwargs={"prompt": prompt},
return_source_documents=True
)Example Queries
# How do I configure BGP on SR Linux?
$ python query.py "How do I configure eBGP peering on SR Linux with a specific local-as?"
# SROS MPLS config
$ python query.py "What is the CLI to enable LDP on an interface in SROS?"
# Troubleshooting
$ python query.py "How do I check OSPF neighbor state in SR Linux?"Supported Router Platforms
| Platform | Documentation Source |
|---|---|
| SR Linux | Nokia SR Linux docs (JSON/CLI model) |
| SROS | Nokia SROS CLI reference |
| SR-SIM | SR Linux simulation docs |
Running Fully Local
Everything runs on your machine — no data leaves your environment:
# Pull a local LLM via Ollama
ollama pull mistral
# Ingest Nokia documentation
python ingest.py --docs ./nokia-docs/ --output ./vectorstore/
# Query the agent
python query.py "How do I configure IS-IS on SR Linux?"Conclusion
router-config-rag makes Nokia router configuration accessible through natural language, grounded in official documentation, with zero cloud dependency. It’s a practical tool for network engineers working in lab environments with SR Linux or SROS.
Source: GitHub