Skip to content

cwccie/netchat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

netchat

RAG-powered network documentation assistant. Chat over Cisco IOS, JunOS, and Arista EOS docs using retrieval-augmented generation with TF-IDF embeddings.

              +-------------------+
              |   User Query      |
              +--------+----------+
                       |
                       v
              +--------+----------+
              |   TF-IDF Embed    |
              +--------+----------+
                       |
                       v
         +-------------+-------------+
         |   Vector Store (cosine)   |
         |   +---------+---------+   |
         |   | Cisco   | JunOS   |   |
         |   | Chunks  | Chunks  |   |
         |   +---------+---------+   |
         |   | Arista  | Custom  |   |
         |   | Chunks  | Docs    |   |
         |   +---------+---------+   |
         +-------------+-------------+
                       |
                       v
              +--------+----------+
              |  Top-K Retrieval  |
              +--------+----------+
                       |
                       v
              +--------+----------+
              |  Prompt Assembly  |
              |  + Conv. History  |
              +--------+----------+
                       |
                       v
              +--------+----------+
              |    LLM Generate   |
              |  (mock / pluggable)|
              +--------+----------+
                       |
                       v
              +--------+----------+
              |   Answer + Sources |
              +-------------------+

Features

  • Document Ingestion -- Load and chunk Markdown, text, and config files from Cisco, Juniper, and Arista. Semantic chunking with configurable overlap preserves context across boundaries.
  • TF-IDF Embeddings -- Pure Python + numpy vector embeddings with no external API. In-memory vector store with cosine similarity search.
  • RAG Pipeline -- Query, retrieve relevant chunks, construct prompt with context, generate answer. Full retrieval-augmented generation flow.
  • Conversation Memory -- Multi-turn chat with sliding window context management. Token-budget-aware history trimming.
  • Built-in Sample Corpus -- Pre-loaded Cisco IOS command reference, JunOS configuration guide, and Arista EOS operations guide for instant demo.
  • Pluggable LLM -- Mock LLM for offline use; swap in any backend by implementing BaseLLM.
  • Vendor Detection -- Auto-detects Cisco, Juniper, or Arista from content and filenames.

Installation

pip install -e .

For development:

pip install -e ".[dev]"

Usage

Demo Mode

Launch with pre-loaded sample docs:

netchat demo

Ingest Documents

# Single file
netchat ingest docs/cisco-guide.md

# Directory (recursive)
netchat ingest docs/

# Non-recursive
netchat ingest --no-recursive docs/

Chat

# Interactive with demo corpus
netchat chat --demo

# Single query
netchat chat --demo "How to configure OSPF on Cisco?"

Search

# Search without answer generation
netchat search --demo "BGP troubleshooting"

# Control result count
netchat search --demo -k 10 "VXLAN configuration"

Supported File Types

Extension Type Description
.md, .markdown Markdown Vendor docs, guides
.txt, .text, .rst Text Plain text docs
.conf, .cfg Config Generic configs
.ios Config Cisco IOS configs
.junos Config JunOS configs
.eos Config Arista EOS configs

Docker

# Interactive demo
docker compose run --rm chat-api

# Run ingestion worker
docker compose run --rm ingestion-worker

# Search
docker compose run --rm vector-store

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest -v

# Lint
ruff check src/ tests/
ruff format --check src/ tests/

Project Structure

netchat/
  src/netchat/
    __init__.py          # Package metadata
    chunker.py           # Semantic chunking with overlap
    loader.py            # Document loaders (md/txt/config)
    embeddings.py        # TF-IDF vectorization (numpy)
    vectorstore.py       # In-memory cosine similarity search
    llm.py               # Mock LLM + pluggable interface
    conversation.py      # Multi-turn context management
    pipeline.py          # RAG orchestration
    samples.py           # Built-in vendor doc corpus
    cli.py               # Click CLI (ingest/chat/search/demo)
  tests/                 # 20+ pytest tests
  .github/workflows/     # CI (Python 3.11, pytest + ruff)
  Dockerfile             # Multi-stage build
  docker-compose.yml     # chat-api, vector-store, ingestion-worker
  pyproject.toml         # Hatchling build config

License

MIT License - Copyright (c) 2026 Corey Wade

About

RAG-powered network documentation assistant - chat over Cisco/Juniper/Arista docs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors