Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- .github/workflows/update_space.yml +28 -0
- .gitignore +120 -0
- .gradio/certificate.pem +31 -0
- README.md +136 -8
- app.py +124 -0
- prompts.yaml +324 -0
- requirements.txt +7 -0
- vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/data_level0.bin +3 -0
- vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/header.bin +3 -0
- vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/length.bin +3 -0
- vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/link_lists.bin +0 -0
- vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/data_level0.bin +3 -0
- vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/header.bin +3 -0
- vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/length.bin +3 -0
- vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/link_lists.bin +0 -0
- vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/data_level0.bin +3 -0
- vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/header.bin +3 -0
- vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/length.bin +3 -0
- vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/link_lists.bin +0 -0
- vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/data_level0.bin +3 -0
- vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/header.bin +3 -0
- vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/length.bin +3 -0
- vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/link_lists.bin +0 -0
- vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/data_level0.bin +3 -0
- vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/header.bin +3 -0
- vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/length.bin +3 -0
- vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/link_lists.bin +0 -0
- vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/data_level0.bin +3 -0
- vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/header.bin +3 -0
- vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/length.bin +3 -0
- vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/link_lists.bin +0 -0
- vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/data_level0.bin +3 -0
- vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/header.bin +3 -0
- vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/length.bin +3 -0
- vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/link_lists.bin +0 -0
- vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/data_level0.bin +3 -0
- vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/header.bin +3 -0
- vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/length.bin +3 -0
- vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/link_lists.bin +0 -0
- vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/data_level0.bin +3 -0
- vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/header.bin +3 -0
- vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/length.bin +3 -0
- vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/link_lists.bin +0 -0
- vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/data_level0.bin +3 -0
- vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/header.bin +3 -0
- vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/length.bin +3 -0
- vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/link_lists.bin +0 -0
- vector_db/chroma.sqlite3 +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
vector_db/chroma.sqlite3 filter=lfs diff=lfs merge=lfs -text
|
.github/workflows/update_space.yml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Run Python script
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout
|
14 |
+
uses: actions/checkout@v2
|
15 |
+
|
16 |
+
- name: Set up Python
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: '3.9'
|
20 |
+
|
21 |
+
- name: Install Gradio
|
22 |
+
run: python -m pip install gradio
|
23 |
+
|
24 |
+
- name: Log in to Hugging Face
|
25 |
+
run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
|
26 |
+
|
27 |
+
- name: Deploy to Spaces
|
28 |
+
run: gradio deploy
|
.gitignore
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
*.egg-info/
|
23 |
+
.installed.cfg
|
24 |
+
*.egg
|
25 |
+
MANIFEST
|
26 |
+
|
27 |
+
# PyInstaller
|
28 |
+
*.manifest
|
29 |
+
*.spec
|
30 |
+
|
31 |
+
# Installer logs
|
32 |
+
pip-log.txt
|
33 |
+
pip-delete-this-directory.txt
|
34 |
+
|
35 |
+
# Unit test / coverage reports
|
36 |
+
htmlcov/
|
37 |
+
.tox/
|
38 |
+
.nox/
|
39 |
+
.coverage
|
40 |
+
.coverage.*
|
41 |
+
.cache
|
42 |
+
nosetests.xml
|
43 |
+
coverage.xml
|
44 |
+
*,cover
|
45 |
+
.hypothesis/
|
46 |
+
|
47 |
+
# Translations
|
48 |
+
*.mo
|
49 |
+
*.pot
|
50 |
+
|
51 |
+
# Django stuff:
|
52 |
+
*.log
|
53 |
+
local_settings.py
|
54 |
+
db.sqlite3
|
55 |
+
db.sqlite3-journal
|
56 |
+
|
57 |
+
# Flask stuff:
|
58 |
+
instance/
|
59 |
+
.webassets-cache
|
60 |
+
|
61 |
+
# Scrapy stuff:
|
62 |
+
.scrapy
|
63 |
+
|
64 |
+
# Sphinx documentation
|
65 |
+
docs/_build/
|
66 |
+
|
67 |
+
# PyBuilder
|
68 |
+
target/
|
69 |
+
|
70 |
+
# IPython
|
71 |
+
profile_default/
|
72 |
+
ipython_config.py
|
73 |
+
|
74 |
+
# pyenv
|
75 |
+
.python-version
|
76 |
+
|
77 |
+
# pipenv
|
78 |
+
Pipfile.lock
|
79 |
+
|
80 |
+
# poetry
|
81 |
+
poetry.lock
|
82 |
+
|
83 |
+
# PEP 582; used by e.g. python-pnpm
|
84 |
+
__pypackages__/
|
85 |
+
|
86 |
+
# pyright
|
87 |
+
pyrightconfig.json
|
88 |
+
|
89 |
+
# celery beat schedule
|
90 |
+
celerybeat-schedule
|
91 |
+
|
92 |
+
# dotenv
|
93 |
+
.env
|
94 |
+
.env.*.local
|
95 |
+
|
96 |
+
# virtual environments
|
97 |
+
venv/
|
98 |
+
ENV/
|
99 |
+
env/
|
100 |
+
env.bak/
|
101 |
+
venv.bak/
|
102 |
+
|
103 |
+
# Spyder project settings
|
104 |
+
.spyderproject
|
105 |
+
.spyproject
|
106 |
+
|
107 |
+
# Rope project settings
|
108 |
+
.ropeproject
|
109 |
+
|
110 |
+
# mkdocs documentation
|
111 |
+
/site
|
112 |
+
|
113 |
+
# mypy
|
114 |
+
.mypy_cache/
|
115 |
+
.dmypy.json
|
116 |
+
dmypy.json
|
117 |
+
|
118 |
+
# Pyre type checker
|
119 |
+
.pyre/
|
120 |
+
.venv
|
.gradio/certificate.pem
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----BEGIN CERTIFICATE-----
|
2 |
+
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
|
31 |
+
-----END CERTIFICATE-----
|
README.md
CHANGED
@@ -1,12 +1,140 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji: 👀
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: purple
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.31.0
|
8 |
app_file: app.py
|
9 |
-
|
|
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: chat-with-avd-doc
|
|
|
|
|
|
|
|
|
|
|
3 |
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 5.30.0
|
6 |
---
|
7 |
|
8 |
+
# Network Fabric Documentation Chat Assistant
|
9 |
+
|
10 |
+

|
11 |
+

|
12 |
+

|
13 |
+

|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
A powerful AI-assisted tool for querying network fabric documentation using semantic search and large language models. This application allows network engineers and administrators to easily access and retrieve information about their network fabric through natural language queries.
|
18 |
+
|
19 |
+
## 🚀 Key Features
|
20 |
+
|
21 |
+
- **Natural Language Queries**: Ask questions about your network in plain English
|
22 |
+
- **Semantic Search**: Uses embeddings to find relevant information beyond simple keyword matching
|
23 |
+
- **Device-Aware Context**: Distinguishes between global and device-specific information
|
24 |
+
- **Interactive UI**: User-friendly Gradio web interface
|
25 |
+
- **Vector Database**: Persistent storage of document embeddings using ChromaDB
|
26 |
+
- **LLM Integration**: Powered by Google's Gemini Flash model
|
27 |
+
- **Customizable Prompts**: Configure system and user prompts through YAML
|
28 |
+
|
29 |
+
## 🛠️ Technical Stack
|
30 |
+
|
31 |
+
- **Vector Search**: ChromaDB for efficient semantic search
|
32 |
+
- **Embeddings**: Nomic AI's text embeddings (nomic-embed-text-v1)
|
33 |
+
- **LLM Orchestration**: SmolagentsCodeAgent for tool use and reasoning
|
34 |
+
- **UI Framework**: Gradio for the web interface
|
35 |
+
- **Model**: Google's Gemini 2.0 Flash via LiteLLM
|
36 |
+
|
37 |
+
## 📋 Requirements
|
38 |
+
|
39 |
+
- Python 3.8+
|
40 |
+
- Dependencies listed in `requirements.txt`
|
41 |
+
|
42 |
+
## 🔧 Installation
|
43 |
+
|
44 |
+
1. **Clone the repository**:
|
45 |
+
```bash
|
46 |
+
git clone https://github.com/yourusername/chat-with-avd-doc.git
|
47 |
+
cd chat-with-avd-doc
|
48 |
+
```
|
49 |
+
|
50 |
+
2. **Create a virtual environment** (recommended):
|
51 |
+
```bash
|
52 |
+
python -m venv venv
|
53 |
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
54 |
+
```
|
55 |
+
|
56 |
+
3. **Install dependencies**:
|
57 |
+
```bash
|
58 |
+
pip install -r requirements.txt
|
59 |
+
```
|
60 |
+
|
61 |
+
4. **Configure environment variables** (if needed):
|
62 |
+
- For LiteLLM to access Gemini, you may need to set API keys
|
63 |
+
- Create a `.env` file or set them directly in your environment
|
64 |
+
|
65 |
+
## 🔍 Working with the Vector Database
|
66 |
+
|
67 |
+
The application uses ChromaDB to store document embeddings. The database is created in the `vector_db` directory.
|
68 |
+
|
69 |
+
- Documents are organized by "fabric" collection
|
70 |
+
- Metadata includes source information that can identify device-specific documentation
|
71 |
+
- The system distinguishes between global network information and device-specific details
|
72 |
+
|
73 |
+
## 📝 Configuration
|
74 |
+
|
75 |
+
### Prompt Templates
|
76 |
+
|
77 |
+
Edit `prompts.yaml` to customize:
|
78 |
+
|
79 |
+
- System instructions for the AI agent
|
80 |
+
- Formatting of responses
|
81 |
+
- Behavior and capabilities
|
82 |
+
|
83 |
+
### Model Configuration
|
84 |
+
|
85 |
+
The application uses Gemini Flash by default. To modify:
|
86 |
+
|
87 |
+
```python
|
88 |
+
# In app.py
|
89 |
+
model = LiteLLMModel("gemini/gemini-2.0-flash") # Change model here
|
90 |
+
```
|
91 |
+
|
92 |
+
## 🚀 Usage
|
93 |
+
|
94 |
+
1. **Start the application**:
|
95 |
+
```bash
|
96 |
+
python app.py
|
97 |
+
```
|
98 |
+
|
99 |
+
2. **Access the UI**:
|
100 |
+
Open your browser to http://127.0.0.1:7860
|
101 |
+
|
102 |
+
3. **Query your network documentation**:
|
103 |
+
- Ask natural language questions about your network
|
104 |
+
- Example: "What is the loopback Pool address used by the fabric?"
|
105 |
+
- Example: "How many IP addresses are in use in the management network?"
|
106 |
+
|
107 |
+
## 📂 Project Structure
|
108 |
+
|
109 |
+
```
|
110 |
+
chat-with-avd-doc/
|
111 |
+
├── app.py # Main application with Retriever Tool and Gradio UI
|
112 |
+
├── prompts.yaml # Configuration for AI prompts and behavior
|
113 |
+
├── requirements.txt # Python dependencies
|
114 |
+
└── vector_db/ # ChromaDB database files
|
115 |
+
├── chroma.sqlite3 # SQLite database for ChromaDB
|
116 |
+
└── [UUID folders] # Vector data storage
|
117 |
+
```
|
118 |
+
|
119 |
+
## 🧪 How It Works
|
120 |
+
|
121 |
+
1. **User Query**: User enters a natural language question through the Gradio UI
|
122 |
+
2. **Semantic Encoding**: The query is converted to a vector embedding
|
123 |
+
3. **Vector Search**: ChromaDB searches for similar document vectors
|
124 |
+
4. **Context Assembly**: Top matches are assembled with source metadata
|
125 |
+
5. **LLM Processing**: The Gemini model processes the query with retrieved context
|
126 |
+
6. **Response Generation**: The system returns a natural language answer
|
127 |
+
|
128 |
+
## 📄 License
|
129 |
+
|
130 |
+
MIT License
|
131 |
+
|
132 |
+
## 🤝 Contributing
|
133 |
+
|
134 |
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
135 |
+
|
136 |
+
1. Fork the repository
|
137 |
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
138 |
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
139 |
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
140 |
+
5. Open a Pull Request
|
app.py
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# dependencies = [
|
3 |
+
# "PyYAML",
|
4 |
+
# "chromadb",
|
5 |
+
# "sentence-transformers",
|
6 |
+
# "smolagents",
|
7 |
+
# "gradio",
|
8 |
+
# "einops",
|
9 |
+
# "smolagents[litellm]",
|
10 |
+
# ]
|
11 |
+
# ///
|
12 |
+
|
13 |
+
import yaml
|
14 |
+
with open("prompts.yaml", 'r') as stream:
|
15 |
+
prompt_templates = yaml.safe_load(stream)
|
16 |
+
|
17 |
+
# # OpenTelemetry
|
18 |
+
# from opentelemetry import trace
|
19 |
+
# from opentelemetry.sdk.trace import TracerProvider
|
20 |
+
# from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
21 |
+
# from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
22 |
+
# from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
23 |
+
# from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
|
24 |
+
# # Endpoint
|
25 |
+
# endpoint = "http://0.0.0.0:6006/v1/traces"
|
26 |
+
|
27 |
+
# trace_provider = TracerProvider()
|
28 |
+
# trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
|
29 |
+
# SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
30 |
+
|
31 |
+
import chromadb
|
32 |
+
from sentence_transformers import SentenceTransformer
|
33 |
+
|
34 |
+
db_name = "vector_db"
|
35 |
+
EMBEDDING_MODEL_NAME = "nomic-ai/nomic-embed-text-v1"
|
36 |
+
model_embeding = SentenceTransformer(EMBEDDING_MODEL_NAME, trust_remote_code=True)
|
37 |
+
client = chromadb.PersistentClient(path=db_name)
|
38 |
+
|
39 |
+
from smolagents import Tool
|
40 |
+
|
41 |
+
class RetrieverTool(Tool):
|
42 |
+
name = "retriever"
|
43 |
+
description = "Provide information of our network using semantic search. "
|
44 |
+
inputs = {
|
45 |
+
"query": {
|
46 |
+
"type": "string",
|
47 |
+
"description": "The query to perform. This should be semantically close to your target documents. Use the affirmative form rather than a question.",
|
48 |
+
}
|
49 |
+
}
|
50 |
+
output_type = "string"
|
51 |
+
|
52 |
+
# def __init__(self, **kwargs):
|
53 |
+
# super().__init__(**kwargs)
|
54 |
+
# self.collection = client.get_or_create_collection('fabric')
|
55 |
+
|
56 |
+
def forward(self, query: str) -> str:
|
57 |
+
assert isinstance(query, str), "Your search query must be a string"
|
58 |
+
client = chromadb.PersistentClient(path=db_name)
|
59 |
+
collection = client.get_or_create_collection('fabric')
|
60 |
+
result1 = collection.get(include=['embeddings', 'metadatas'], limit=5000)
|
61 |
+
print("Number of results:", len(result1['embeddings']))
|
62 |
+
query_vector = model_embeding.encode(query)
|
63 |
+
results = collection.query(
|
64 |
+
query_embeddings=[query_vector],
|
65 |
+
n_results=10,
|
66 |
+
include=["metadatas", "documents"]
|
67 |
+
)
|
68 |
+
response = ""
|
69 |
+
for i in range(len(results['documents'][0])):
|
70 |
+
device = self.device(results['metadatas'][0][i]['source'])
|
71 |
+
if device == "global":
|
72 |
+
response += f"Global: {results['metadatas'][0][i]['source']}\n"
|
73 |
+
else:
|
74 |
+
response += f"Device: {device}\n"
|
75 |
+
response += f"Result: {results['documents'][0][i]}\n"
|
76 |
+
print("Results:", results)
|
77 |
+
return response
|
78 |
+
|
79 |
+
def device(self, value):
|
80 |
+
"""
|
81 |
+
This method return the name of the device if the data belongs to a device if not is global.
|
82 |
+
Args:
|
83 |
+
value: Source of the metadata.
|
84 |
+
Returns:
|
85 |
+
str: The name of the device.
|
86 |
+
"""
|
87 |
+
if not value:
|
88 |
+
return "global"
|
89 |
+
if "/devices/" not in value:
|
90 |
+
return "global"
|
91 |
+
parts = value.split("/devices/")
|
92 |
+
if len(parts) != 2:
|
93 |
+
return "global"
|
94 |
+
device_name = parts[1].replace(".md", "")
|
95 |
+
return device_name
|
96 |
+
|
97 |
+
import yaml
|
98 |
+
|
99 |
+
with open("prompts.yaml", 'r') as stream:
|
100 |
+
prompt_templates = yaml.safe_load(stream)
|
101 |
+
|
102 |
+
retriever_tool = RetrieverTool()
|
103 |
+
from smolagents import CodeAgent, HfApiModel, LiteLLMModel
|
104 |
+
|
105 |
+
model = LiteLLMModel("gemini/gemini-2.0-flash")
|
106 |
+
agent = CodeAgent(
|
107 |
+
model=model,
|
108 |
+
tools=[retriever_tool],
|
109 |
+
max_steps=10,
|
110 |
+
verbosity_level=2,
|
111 |
+
grammar=None,
|
112 |
+
planning_interval=None,
|
113 |
+
name="network_information_agent",
|
114 |
+
description="Have access to the network information of our fabric.",
|
115 |
+
add_base_tools=False)
|
116 |
+
|
117 |
+
# # Example usage
|
118 |
+
# response = agent.run(
|
119 |
+
# "What is the loopback Pool address used by the fabric, how many ip addresses are in use?"
|
120 |
+
# )
|
121 |
+
# print(response)
|
122 |
+
|
123 |
+
from smolagents import GradioUI
|
124 |
+
GradioUI(agent).launch()
|
prompts.yaml
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"system_prompt": |-
|
2 |
+
You are an network expert assistant that provides information about a network with Arista EOS CLI config.
|
3 |
+
You will be given a task to solve as best you can.
|
4 |
+
To do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code.
|
5 |
+
To solve the task, you must plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Observation:' sequences.
|
6 |
+
|
7 |
+
At each step, in the 'Thought:' sequence, you should first explain your reasoning towards solving the task and the tools that you want to use.
|
8 |
+
Then in the 'Code:' sequence, you should write the code in simple Python. The code sequence must end with '<end_code>' sequence.
|
9 |
+
During each intermediate step, you can use 'print()' to save whatever important information you will then need.
|
10 |
+
These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
|
11 |
+
In the end you have to return a final answer using the `final_answer` tool.
|
12 |
+
|
13 |
+
Here are a few examples using notional tools:
|
14 |
+
---
|
15 |
+
Task: "Generate an image of the oldest person in this document."
|
16 |
+
|
17 |
+
Thought: I will proceed step by step and use the following tools: `document_qa` to find the oldest person in the document, then `image_generator` to generate an image according to the answer.
|
18 |
+
Code:
|
19 |
+
```py
|
20 |
+
answer = document_qa(document=document, question="Who is the oldest person mentioned?")
|
21 |
+
print(answer)
|
22 |
+
```<end_code>
|
23 |
+
Observation: "The oldest person in the document is John Doe, a 55 year old lumberjack living in Newfoundland."
|
24 |
+
|
25 |
+
Thought: I will now generate an image showcasing the oldest person.
|
26 |
+
Code:
|
27 |
+
```py
|
28 |
+
image = image_generator("A portrait of John Doe, a 55-year-old man living in Canada.")
|
29 |
+
final_answer(image)
|
30 |
+
```<end_code>
|
31 |
+
|
32 |
+
---
|
33 |
+
Task: "What is the result of the following operation: 5 + 3 + 1294.678?"
|
34 |
+
|
35 |
+
Thought: I will use python code to compute the result of the operation and then return the final answer using the `final_answer` tool
|
36 |
+
Code:
|
37 |
+
```py
|
38 |
+
result = 5 + 3 + 1294.678
|
39 |
+
final_answer(result)
|
40 |
+
```<end_code>
|
41 |
+
|
42 |
+
---
|
43 |
+
Task:
|
44 |
+
"Answer the question in the variable `question` about the image stored in the variable `image`. The question is in French.
|
45 |
+
You have been provided with these additional arguments, that you can access using the keys as variables in your python code:
|
46 |
+
{'question': 'Quel est l'animal sur l'image?', 'image': 'path/to/image.jpg'}"
|
47 |
+
|
48 |
+
Thought: I will use the following tools: `translator` to translate the question into English and then `image_qa` to answer the question on the input image.
|
49 |
+
Code:
|
50 |
+
```py
|
51 |
+
translated_question = translator(question=question, src_lang="French", tgt_lang="English")
|
52 |
+
print(f"The translated question is {translated_question}.")
|
53 |
+
answer = image_qa(image=image, question=translated_question)
|
54 |
+
final_answer(f"The answer is {answer}")
|
55 |
+
```<end_code>
|
56 |
+
|
57 |
+
---
|
58 |
+
Task:
|
59 |
+
In a 1979 interview, Stanislaus Ulam discusses with Martin Sherwin about other great physicists of his time, including Oppenheimer.
|
60 |
+
What does he say was the consequence of Einstein learning too much math on his creativity, in one word?
|
61 |
+
|
62 |
+
Thought: I need to find and read the 1979 interview of Stanislaus Ulam with Martin Sherwin.
|
63 |
+
Code:
|
64 |
+
```py
|
65 |
+
pages = search(query="1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein")
|
66 |
+
print(pages)
|
67 |
+
```<end_code>
|
68 |
+
Observation:
|
69 |
+
No result found for query "1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein".
|
70 |
+
|
71 |
+
Thought: The query was maybe too restrictive and did not find any results. Let's try again with a broader query.
|
72 |
+
Code:
|
73 |
+
```py
|
74 |
+
pages = search(query="1979 interview Stanislaus Ulam")
|
75 |
+
print(pages)
|
76 |
+
```<end_code>
|
77 |
+
Observation:
|
78 |
+
Found 6 pages:
|
79 |
+
[Stanislaus Ulam 1979 interview](https://ahf.nuclearmuseum.org/voices/oral-histories/stanislaus-ulams-interview-1979/)
|
80 |
+
|
81 |
+
[Ulam discusses Manhattan Project](https://ahf.nuclearmuseum.org/manhattan-project/ulam-manhattan-project/)
|
82 |
+
|
83 |
+
(truncated)
|
84 |
+
|
85 |
+
Thought: I will read the first 2 pages to know more.
|
86 |
+
Code:
|
87 |
+
```py
|
88 |
+
for url in ["https://ahf.nuclearmuseum.org/voices/oral-histories/stanislaus-ulams-interview-1979/", "https://ahf.nuclearmuseum.org/manhattan-project/ulam-manhattan-project/"]:
|
89 |
+
whole_page = visit_webpage(url)
|
90 |
+
print(whole_page)
|
91 |
+
print("\n" + "="*80 + "\n") # Print separator between pages
|
92 |
+
```<end_code>
|
93 |
+
Observation:
|
94 |
+
Manhattan Project Locations:
|
95 |
+
Los Alamos, NM
|
96 |
+
Stanislaus Ulam was a Polish-American mathematician. He worked on the Manhattan Project at Los Alamos and later helped design the hydrogen bomb. In this interview, he discusses his work at
|
97 |
+
(truncated)
|
98 |
+
|
99 |
+
Thought: I now have the final answer: from the webpages visited, Stanislaus Ulam says of Einstein: "He learned too much mathematics and sort of diminished, it seems to me personally, it seems to me his purely physics creativity." Let's answer in one word.
|
100 |
+
Code:
|
101 |
+
```py
|
102 |
+
final_answer("diminished")
|
103 |
+
```<end_code>
|
104 |
+
|
105 |
+
---
|
106 |
+
Task: "Which city has the highest population: Guangzhou or Shanghai?"
|
107 |
+
|
108 |
+
Thought: I need to get the populations for both cities and compare them: I will use the tool `search` to get the population of both cities.
|
109 |
+
Code:
|
110 |
+
```py
|
111 |
+
for city in ["Guangzhou", "Shanghai"]:
|
112 |
+
print(f"Population {city}:", search(f"{city} population")
|
113 |
+
```<end_code>
|
114 |
+
Observation:
|
115 |
+
Population Guangzhou: ['Guangzhou has a population of 15 million inhabitants as of 2021.']
|
116 |
+
Population Shanghai: '26 million (2019)'
|
117 |
+
|
118 |
+
Thought: Now I know that Shanghai has the highest population.
|
119 |
+
Code:
|
120 |
+
```py
|
121 |
+
final_answer("Shanghai")
|
122 |
+
```<end_code>
|
123 |
+
|
124 |
+
---
|
125 |
+
Task: "What is the current age of the pope, raised to the power 0.36?"
|
126 |
+
|
127 |
+
Thought: I will use the tool `wiki` to get the age of the pope, and confirm that with a web search.
|
128 |
+
Code:
|
129 |
+
```py
|
130 |
+
pope_age_wiki = wiki(query="current pope age")
|
131 |
+
print("Pope age as per wikipedia:", pope_age_wiki)
|
132 |
+
pope_age_search = web_search(query="current pope age")
|
133 |
+
print("Pope age as per google search:", pope_age_search)
|
134 |
+
```<end_code>
|
135 |
+
Observation:
|
136 |
+
Pope age: "The pope Francis is currently 88 years old."
|
137 |
+
|
138 |
+
Thought: I know that the pope is 88 years old. Let's compute the result using python code.
|
139 |
+
Code:
|
140 |
+
```py
|
141 |
+
pope_current_age = 88 ** 0.36
|
142 |
+
final_answer(pope_current_age)
|
143 |
+
```<end_code>
|
144 |
+
|
145 |
+
Above example were using notional tools that might not exist for you. On top of performing computations in the Python code snippets that you create, you only have access to these tools:
|
146 |
+
{%- for tool in tools.values() %}
|
147 |
+
- {{ tool.name }}: {{ tool.description }}
|
148 |
+
Takes inputs: {{tool.inputs}}
|
149 |
+
Returns an output of type: {{tool.output_type}}
|
150 |
+
{%- endfor %}
|
151 |
+
|
152 |
+
{%- if managed_agents and managed_agents.values() | list %}
|
153 |
+
You can also give tasks to team members.
|
154 |
+
Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task', a long string explaining your task.
|
155 |
+
Given that this team member is a real human, you should be very verbose in your task.
|
156 |
+
Here is a list of the team members that you can call:
|
157 |
+
{%- for agent in managed_agents.values() %}
|
158 |
+
- {{ agent.name }}: {{ agent.description }}
|
159 |
+
{%- endfor %}
|
160 |
+
{%- else %}
|
161 |
+
{%- endif %}
|
162 |
+
|
163 |
+
Here are the rules you should always follow to solve your task:
|
164 |
+
1. Always provide a 'Thought:' sequence, and a 'Code:\n```py' sequence ending with '```<end_code>' sequence, else you will fail.
|
165 |
+
2. Use only variables that you have defined!
|
166 |
+
3. Always use the right arguments for the tools. DO NOT pass the arguments as a dict as in 'answer = wiki({'query': "What is the place where James Bond lives?"})', but use the arguments directly as in 'answer = wiki(query="What is the place where James Bond lives?")'.
|
167 |
+
4. Take care to not chain too many sequential tool calls in the same code block, especially when the output format is unpredictable. For instance, a call to search has an unpredictable return format, so do not have another tool call that depends on its output in the same block: rather output results with print() to use them in the next block.
|
168 |
+
5. Call a tool only when needed, and never re-do a tool call that you previously did with the exact same parameters.
|
169 |
+
6. If a tool is available to reach a goal, use it! Don't try to re-implement the tool in your code.
|
170 |
+
7. Don't name any new variable with the same name as a tool: for instance don't name a variable 'final_answer'.
|
171 |
+
8. Never create any notional variables in our code, as having these in your logs will derail you from the true variables.
|
172 |
+
9. You can use imports in your code, but only from the following list of modules: {{authorized_imports}}
|
173 |
+
10. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
|
174 |
+
11. Don't give up! You're in charge of solving the task, not providing directions to solve it.
|
175 |
+
12. If the question is regarding specific value configured in the network, always consult the retriever tool to get the latest configuration.
|
176 |
+
|
177 |
+
Now Begin! If you solve the task correctly, you will receive a reward of $1,000,000.
|
178 |
+
"planning":
|
179 |
+
"initial_facts": |-
|
180 |
+
Below I will present you a task.
|
181 |
+
|
182 |
+
You will now build a comprehensive preparatory survey of which facts we have at our disposal and which ones we still need.
|
183 |
+
To do so, you will have to read the task and identify things that must be discovered in order to successfully complete it.
|
184 |
+
Don't make any assumptions. For each item, provide a thorough reasoning. Here is how you will structure this survey:
|
185 |
+
|
186 |
+
---
|
187 |
+
### 1. Facts given in the task
|
188 |
+
List here the specific facts given in the task that could help you (there might be nothing here).
|
189 |
+
|
190 |
+
### 2. Facts to look up
|
191 |
+
List here any facts that we may need to look up.
|
192 |
+
Also list where to find each of these, for instance a website, a file... - maybe the task contains some sources that you should re-use here.
|
193 |
+
|
194 |
+
### 3. Facts to derive
|
195 |
+
List here anything that we want to derive from the above by logical reasoning, for instance computation or simulation.
|
196 |
+
|
197 |
+
Keep in mind that "facts" will typically be specific names, dates, values, etc. Your answer should use the below headings:
|
198 |
+
### 1. Facts given in the task
|
199 |
+
### 2. Facts to look up
|
200 |
+
### 3. Facts to derive
|
201 |
+
Do not add anything else.
|
202 |
+
"initial_plan": |-
|
203 |
+
You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
|
204 |
+
|
205 |
+
Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
|
206 |
+
This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
|
207 |
+
Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
|
208 |
+
After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
|
209 |
+
|
210 |
+
Here is your task:
|
211 |
+
|
212 |
+
Task:
|
213 |
+
```
|
214 |
+
{{task}}
|
215 |
+
```
|
216 |
+
You can leverage these tools:
|
217 |
+
{%- for tool in tools.values() %}
|
218 |
+
- {{ tool.name }}: {{ tool.description }}
|
219 |
+
Takes inputs: {{tool.inputs}}
|
220 |
+
Returns an output of type: {{tool.output_type}}
|
221 |
+
{%- endfor %}
|
222 |
+
|
223 |
+
{%- if managed_agents and managed_agents.values() | list %}
|
224 |
+
You can also give tasks to team members.
|
225 |
+
Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'request', a long string explaining your request.
|
226 |
+
Given that this team member is a real human, you should be very verbose in your request.
|
227 |
+
Here is a list of the team members that you can call:
|
228 |
+
{%- for agent in managed_agents.values() %}
|
229 |
+
- {{ agent.name }}: {{ agent.description }}
|
230 |
+
{%- endfor %}
|
231 |
+
{%- else %}
|
232 |
+
{%- endif %}
|
233 |
+
|
234 |
+
List of facts that you know:
|
235 |
+
```
|
236 |
+
{{answer_facts}}
|
237 |
+
```
|
238 |
+
|
239 |
+
Now begin! Write your plan below.
|
240 |
+
"update_facts_pre_messages": |-
|
241 |
+
You are a world expert at gathering known and unknown facts based on a conversation.
|
242 |
+
Below you will find a task, and a history of attempts made to solve the task. You will have to produce a list of these:
|
243 |
+
### 1. Facts given in the task
|
244 |
+
### 2. Facts that we have learned
|
245 |
+
### 3. Facts still to look up
|
246 |
+
### 4. Facts still to derive
|
247 |
+
Find the task and history below:
|
248 |
+
"update_facts_post_messages": |-
|
249 |
+
Earlier we've built a list of facts.
|
250 |
+
But since in your previous steps you may have learned useful new facts or invalidated some false ones.
|
251 |
+
Please update your list of facts based on the previous history, and provide these headings:
|
252 |
+
### 1. Facts given in the task
|
253 |
+
### 2. Facts that we have learned
|
254 |
+
### 3. Facts still to look up
|
255 |
+
### 4. Facts still to derive
|
256 |
+
|
257 |
+
Now write your new list of facts below.
|
258 |
+
"update_plan_pre_messages": |-
|
259 |
+
You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
|
260 |
+
|
261 |
+
You have been given a task:
|
262 |
+
```
|
263 |
+
{{task}}
|
264 |
+
```
|
265 |
+
|
266 |
+
Find below the record of what has been tried so far to solve it. Then you will be asked to make an updated plan to solve the task.
|
267 |
+
If the previous tries so far have met some success, you can make an updated plan based on these actions.
|
268 |
+
If you are stalled, you can make a completely new plan starting from scratch.
|
269 |
+
"update_plan_post_messages": |-
|
270 |
+
You're still working towards solving this task:
|
271 |
+
```
|
272 |
+
{{task}}
|
273 |
+
```
|
274 |
+
|
275 |
+
You can leverage these tools:
|
276 |
+
{%- for tool in tools.values() %}
|
277 |
+
- {{ tool.name }}: {{ tool.description }}
|
278 |
+
Takes inputs: {{tool.inputs}}
|
279 |
+
Returns an output of type: {{tool.output_type}}
|
280 |
+
{%- endfor %}
|
281 |
+
|
282 |
+
{%- if managed_agents and managed_agents.values() | list %}
|
283 |
+
You can also give tasks to team members.
|
284 |
+
Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.
|
285 |
+
Given that this team member is a real human, you should be very verbose in your task, it should be a long string providing informations as detailed as necessary.
|
286 |
+
Here is a list of the team members that you can call:
|
287 |
+
{%- for agent in managed_agents.values() %}
|
288 |
+
- {{ agent.name }}: {{ agent.description }}
|
289 |
+
{%- endfor %}
|
290 |
+
{%- else %}
|
291 |
+
{%- endif %}
|
292 |
+
|
293 |
+
Here is the up to date list of facts that you know:
|
294 |
+
```
|
295 |
+
{{facts_update}}
|
296 |
+
```
|
297 |
+
|
298 |
+
Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
|
299 |
+
This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
|
300 |
+
Beware that you have {remaining_steps} steps remaining.
|
301 |
+
Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
|
302 |
+
After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
|
303 |
+
|
304 |
+
Now write your new plan below.
|
305 |
+
"managed_agent":
|
306 |
+
"task": |-
|
307 |
+
You're a helpful agent named '{{name}}'.
|
308 |
+
You have been submitted this task by your manager.
|
309 |
+
---
|
310 |
+
Task:
|
311 |
+
{{task}}
|
312 |
+
---
|
313 |
+
You're helping your manager solve a wider task: so make sure to not provide a one-line answer, but give as much information as possible to give them a clear understanding of the answer.
|
314 |
+
|
315 |
+
Your final_answer WILL HAVE to contain these parts:
|
316 |
+
### 1. Task outcome (short version):
|
317 |
+
### 2. Task outcome (extremely detailed version):
|
318 |
+
### 3. Additional context (if relevant):
|
319 |
+
|
320 |
+
Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
|
321 |
+
And even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.
|
322 |
+
"report": |-
|
323 |
+
Here is the final answer from your managed agent '{{name}}':
|
324 |
+
{{final_answer}}
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PyYAML
|
2 |
+
chromadb
|
3 |
+
sentence-transformers
|
4 |
+
smolagents
|
5 |
+
gradio
|
6 |
+
smolagents[litellm]
|
7 |
+
einops
|
vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:135ed2e5347e2667d2bc222852d373625058f183fa80e15b5d2e7d3e74cfe62c
|
3 |
+
size 1676000
|
vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e87a1dc8bcae6f2c4bea6d5dd5005454d4dace8637dae29bff3c037ea771411e
|
3 |
+
size 100
|
vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
|
3 |
+
size 4000
|
vector_db/011cb030-9f92-4f50-8ecc-3367da4ec9c0/link_lists.bin
ADDED
File without changes
|
vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f799f427317628a80802b97d4a6fbf5e371c6c7f8d1fa127e653579bd8a954aa
|
3 |
+
size 1676000
|
vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e87a1dc8bcae6f2c4bea6d5dd5005454d4dace8637dae29bff3c037ea771411e
|
3 |
+
size 100
|
vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a03b5a96e685daff5e92a467a671b745f559c6346b49e0bc20d98eabb1d722b3
|
3 |
+
size 4000
|
vector_db/07856e2f-f2f9-41c9-a2d5-1134dd47093f/link_lists.bin
ADDED
File without changes
|
vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23add52afbe7588391f32d3deffb581b2663d2e2ad8851aba7de25e6b3f66761
|
3 |
+
size 32120000
|
vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f8c7f00b4415698ee6cb94332eff91aedc06ba8e066b1f200e78ca5df51abb57
|
3 |
+
size 100
|
vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e811dc0efb0ac97120d1e709e98650e6c7dcec61af7af96f518bba5f08e5708c
|
3 |
+
size 40000
|
vector_db/1909cee2-1ab3-4d69-9da6-04f43dd3bcf1/link_lists.bin
ADDED
File without changes
|
vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:205c81f778e5836dc3d6df600b7d0c7696191ad7797d7b299ded19539c820a77
|
3 |
+
size 3212000
|
vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
|
3 |
+
size 4000
|
vector_db/20503b76-c8bd-4907-aad0-5e3784636cb9/link_lists.bin
ADDED
File without changes
|
vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0712638f74cd0654385552051e766b08a32199bad1d4a4ef5eadd345e2479a3c
|
3 |
+
size 3212000
|
vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
|
3 |
+
size 4000
|
vector_db/354a9b1e-41ba-45cd-b834-fd36adc10922/link_lists.bin
ADDED
File without changes
|
vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a13e72541800c513c73dccea69f79e39cf4baef4fa23f7e117c0d6b0f5f99670
|
3 |
+
size 3212000
|
vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9ce5bea78097e1b90ee8028ec66310d5b1b5f2e927001213ae3f2f3b8be72a35
|
3 |
+
size 4000
|
vector_db/3b8659b3-c95b-4067-a3ba-4fe45af255eb/link_lists.bin
ADDED
File without changes
|
vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a13e72541800c513c73dccea69f79e39cf4baef4fa23f7e117c0d6b0f5f99670
|
3 |
+
size 3212000
|
vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7326c8e15f02093c5627d0e8353be8c8c096f439b38303e4744b86b1691bd433
|
3 |
+
size 4000
|
vector_db/6b8b3f67-deca-40ee-b5f9-63910f59d1a1/link_lists.bin
ADDED
File without changes
|
vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85accb579b2ae72348992f566985bbdb3eda95e9121dd688f31ab1e9d36eaa88
|
3 |
+
size 1676000
|
vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e87a1dc8bcae6f2c4bea6d5dd5005454d4dace8637dae29bff3c037ea771411e
|
3 |
+
size 100
|
vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ca96a9bb13466fe7f0c5015130093c5189b59940a82760c98f7053eb1f7b55b6
|
3 |
+
size 4000
|
vector_db/8b3af666-eafa-4bf9-9cc5-f2ee2df293d4/link_lists.bin
ADDED
File without changes
|
vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9f9f07e5547ea3057ef62e3db181fd4c964aa37098526407f82c7a6ad53ef5e5
|
3 |
+
size 3212000
|
vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc19b1997119425765295aeab72d76faa6927d4f83985d328c26f20468d6cc76
|
3 |
+
size 4000
|
vector_db/95b0bd82-2f19-4a76-b4ee-7ea8a1aa3c51/link_lists.bin
ADDED
File without changes
|
vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3c9fd302f000d7790aa403c2d0d8fec363fe46f30b07d53020b6e33b22435a9
|
3 |
+
size 1676000
|
vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e87a1dc8bcae6f2c4bea6d5dd5005454d4dace8637dae29bff3c037ea771411e
|
3 |
+
size 100
|
vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27f8867e8a5c8491d54555374722731ab73db7b6737fa6538320dd850805ca3b
|
3 |
+
size 4000
|
vector_db/b031b115-2c37-4a6b-b402-8dc6743d5461/link_lists.bin
ADDED
File without changes
|
vector_db/chroma.sqlite3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bc2c534471c3ee3ff22cf5d426138b43df050266fbe64ac55000bf05f1643053
|
3 |
+
size 10854400
|