chat-with-avd-doc / README.md
rogerscuall's picture
Upload folder using huggingface_hub
890d952 verified
|
raw
history blame
4.52 kB
metadata
title: chat-with-avd-doc
app_file: app.py
sdk: gradio
sdk_version: 5.30.0

Network Fabric Documentation Chat Assistant

Network Documentation Python ChromaDB Gemini

Queries network documentation with natural languague. Recommend ports to users

πŸš€ Key Features

  • Natural Language Queries: Ask questions about your network in plain English
  • Semantic Search: Uses embeddings to find relevant information beyond simple keyword matching
  • Device-Aware Context: Distinguishes between global and device-specific information
  • Interactive UI: User-friendly Gradio web interface
  • Vector Database: Persistent storage of document embeddings using ChromaDB
  • LLM Integration: Powered by Google's Gemini Flash model
  • Customizable Prompts: Configure system and user prompts through YAML

πŸ› οΈ Technical Stack

  • Vector Search: ChromaDB for efficient semantic search
  • Embeddings: Nomic AI's text embeddings (nomic-embed-text-v1)
  • LLM Orchestration: SmolagentsCodeAgent for tool use and reasoning
  • UI Framework: Gradio for the web interface
  • Model: Google's Gemini 2.0 Flash via LiteLLM

πŸ“‹ Requirements

  • Python 3.8+
  • Dependencies listed in requirements.txt

πŸ”§ Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/chat-with-avd-doc.git
    cd chat-with-avd-doc
    
  2. Create a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Configure environment variables (if needed):

    • For LiteLLM to access Gemini, you may need to set API keys
    • Create a .env file or set them directly in your environment

πŸ” Working with the Vector Database

The application uses ChromaDB to store document embeddings. The database is created in the vector_db directory.

  • Documents are organized by "fabric" collection
  • Metadata includes source information that can identify device-specific documentation
  • The system distinguishes between global network information and device-specific details

πŸ“ Configuration

Prompt Templates

Edit prompts.yaml to customize:

  • System instructions for the AI agent
  • Formatting of responses
  • Behavior and capabilities

Model Configuration

The application uses Gemini Flash by default. To modify:

# In app.py
model = LiteLLMModel("gemini/gemini-2.0-flash")  # Change model here

πŸš€ Usage

  1. Start the application:

    python app.py
    
  2. Access the UI: Open your browser to http://127.0.0.1:7860

  3. Query your network documentation:

    • Ask natural language questions about your network
    • Example: "What is the loopback Pool address used by the fabric?"
    • Example: "How many IP addresses are in use in the management network?"

πŸ“‚ Project Structure

chat-with-avd-doc/
β”œβ”€β”€ app.py              # Main application with Retriever Tool and Gradio UI
β”œβ”€β”€ prompts.yaml        # Configuration for AI prompts and behavior
β”œβ”€β”€ requirements.txt    # Python dependencies
└── vector_db/          # ChromaDB database files
    β”œβ”€β”€ chroma.sqlite3  # SQLite database for ChromaDB
    └── [UUID folders]  # Vector data storage

πŸ§ͺ How It Works

  1. User Query: User enters a natural language question through the Gradio UI
  2. Semantic Encoding: The query is converted to a vector embedding
  3. Vector Search: ChromaDB searches for similar document vectors
  4. Context Assembly: Top matches are assembled with source metadata
  5. LLM Processing: The Gemini model processes the query with retrieved context
  6. Response Generation: The system returns a natural language answer

πŸ“„ License

MIT License

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Test Questions

  1. What is the name server in this network? 8.8.8.8