Spaces:
Sleeping
Sleeping
metadata
title: chat-with-avd-doc
app_file: app.py
sdk: gradio
sdk_version: 5.30.0
Network Fabric Documentation Chat Assistant
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
Clone the repository:
git clone https://github.com/yourusername/chat-with-avd-doc.git cd chat-with-avd-doc
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
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
Start the application:
python app.py
Access the UI: Open your browser to http://127.0.0.1:7860
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
- User Query: User enters a natural language question through the Gradio UI
- Semantic Encoding: The query is converted to a vector embedding
- Vector Search: ChromaDB searches for similar document vectors
- Context Assembly: Top matches are assembled with source metadata
- LLM Processing: The Gemini model processes the query with retrieved context
- Response Generation: The system returns a natural language answer
π License
MIT License
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Test Questions
- What is the name server in this network? 8.8.8.8