File size: 11,153 Bytes
be34b9e 30f499c be34b9e 30f499c be34b9e 30f499c be34b9e 30f499c be34b9e 30f499c f369a7d be34b9e 30f499c be34b9e 30f499c be34b9e f369a7d be34b9e f369a7d be34b9e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | # Configuration Save/Load Guide
## Overview
The Pub/Sub Multi-Agent System now supports saving and loading complete configurations, allowing you to:
- Save your entire setup (data sources + agents) as a JSON file
- Share configurations with teammates
- Version control your agent pipelines
- Quickly switch between different workflows
## Save Configuration
### How to Save
1. Configure your data sources and agents
2. **(Optional)** Check "☑ Save results" to include execution results
3. Click the **"Save Config"** button in the top-right header
4. A JSON file will download automatically with the name pattern:
```
pubsub-config-YYYY-MM-DD.json
```
### Save Results Checkbox
The **"☑ Save results"** checkbox allows you to include execution results in the saved configuration.
**When checked**, the config includes:
- All configuration data (agents, data sources)
- Final Result box content
- NER Result box content
- Execution Log content
**When unchecked** (default):
- Only configuration data is saved
- No results or logs
**Use cases for saving results**:
- Document successful executions
- Share complete analysis with team
- Archive results with configuration
- Review past executions later
### What Gets Saved
The configuration file includes:
- **Version**: Configuration format version (currently 1.0)
- **Timestamp**: When the config was saved
- **User Question**: Current question text
- **Data Sources**: All data sources with labels and content
- **Agents**: All agent configurations including:
- Title
- Prompt template
- Model selection
- Subscribe/Publish topics
- Show result checkbox state
- **Results** (if "Save results" checked):
- Final Result box content
- NER Result box content
- Execution Log content
### Example Configuration File
**Without Results**:
```json
{
"version": "1.0",
"timestamp": "2026-02-01T10:30:00.000Z",
"userQuestion": "What are the top 10 customers?",
"dataSources": [
{
"label": "Schema",
"content": "Tables:\n- customers (id, name, email)\n- orders (id, customer_id, total)"
}
],
"agents": [
{
"title": "SQL Generator",
"prompt": "Generate SQL for: {question}\nSchema: {schema}",
"model": "phi4-mini",
"subscribeTopic": "START",
"publishTopic": "SQL_GENERATED",
"showResult": true
}
]
}
```
**With Results** (when "Save results" is checked):
```json
{
"version": "1.0",
"timestamp": "2026-02-01T10:30:00.000Z",
"userQuestion": "Extract medical entities from patient note",
"dataSources": [...],
"agents": [...],
"results": {
"finalResult": "--- Entity Extractor ---\n[{\"text\": \"diabetes\", \"entity_type\": \"PROBLEM\"}]",
"nerResult": "Patient has [diabetes:PROBLEM] and takes [metformin:TREATMENT]",
"executionLog": "[10:30:00] ℹ️ Starting...\n[10:30:05] ✅ Complete"
}
}
```
## Load Configuration
### How to Load
1. Click the **"Load Config"** button in the top-right header
2. Select a previously saved JSON configuration file
3. The system will:
- Clear current configuration
- Load all data sources
- Load all agents
- Restore the user question
- Display success message in logs
### What Happens on Load
- **Current config is replaced**: All existing data sources and agents are removed
- **New IDs assigned**: Loaded items get new unique IDs
- **Results restored** (if saved with results):
- Final Result box populated
- NER Result box populated
- Execution Log populated
- **Empty boxes** (if no results saved):
- All result boxes cleared
- **Validation**: File is checked for proper format before loading
### Error Handling
If the configuration file is invalid, you'll see an error message:
```
Failed to load configuration: Invalid configuration file
```
Common issues:
- Wrong file format (not JSON)
- Missing required fields (version, dataSources, agents)
- Corrupted file
## Use Cases
### Use Case 1: Template Workflows
Save common workflows as templates:
**sql-analysis-template.json**
```json
{
"version": "1.0",
"dataSources": [
{"label": "Schema", "content": ""},
{"label": "SampleData", "content": ""}
],
"agents": [
{"title": "Analyzer", "prompt": "...", ...},
{"title": "Generator", "prompt": "...", ...},
{"title": "Validator", "prompt": "...", ...}
]
}
```
Load this template and just fill in the Schema!
### Use Case 2: Team Collaboration
Share configurations with your team:
1. Developer A creates optimal pipeline
2. Saves config: `customer-analysis-pipeline.json`
3. Commits to Git repository
4. Developer B loads config
5. Everyone uses same proven workflow
### Use Case 3: A/B Testing Prompts
Compare different prompt strategies:
**Workflow:**
1. Create pipeline with Approach A
2. Save as `approach-a.json`
3. Modify prompts for Approach B
4. Save as `approach-b.json`
5. Load each config and compare results
### Use Case 4: Different Data Sources
Same agents, different data:
**Workflow:**
1. Create agent pipeline once
2. Save config with empty data sources
3. For each new dataset:
- Load config
- Add new data sources
- Execute
- Save results
### Use Case 5: Version Control
Track evolution of your pipelines:
```bash
git/
├── configs/
│ ├── v1-basic-sql.json
│ ├── v2-with-validation.json
│ ├── v3-multi-step.json
│ └── v4-production.json
```
Load previous versions to compare performance.
## Best Practices
### 1. Naming Conventions
Use descriptive filenames:
```
✅ Good:
- medical-diagnosis-workflow-v2.json
- sql-generator-with-validation.json
- customer-analysis-pipeline.json
❌ Bad:
- config.json
- test.json
- backup.json
```
### 2. Documentation in Configs
Add comments in data sources:
```json
{
"label": "Schema",
"content": "# Customer Database Schema v2.0\n# Last updated: 2026-02-01\n\nTables:\n- customers ..."
}
```
### 3. Version Your Configs
Include version info in data sources:
```json
{
"label": "ConfigInfo",
"content": "Pipeline Version: 3.0\nAuthor: Jane Doe\nPurpose: SQL generation with validation\nLast Modified: 2026-02-01"
}
```
### 4. Organize by Purpose
Create folder structure:
```
configs/
├── sql-generation/
│ ├── basic.json
│ ├── with-validation.json
│ └── with-optimization.json
├── medical-analysis/
│ ├── symptom-analysis.json
│ └── diagnosis-support.json
└── data-analysis/
├── sales-report.json
└── customer-segmentation.json
```
### 5. Template Strategy
Create base templates without data:
```json
{
"dataSources": [
{"label": "Schema", "content": ""},
{"label": "Data", "content": ""}
],
"agents": [ /* fully configured */ ]
}
```
Load template, add data, execute!
### 6. Backup Before Experiments
Before trying new approaches:
1. Save current config
2. Make experimental changes
3. If it works: save new version
4. If it fails: reload backup
## Configuration File Structure
### Required Fields
```json
{
"version": "1.0", // Required: config format version
"dataSources": [], // Required: array (can be empty)
"agents": [] // Required: array (can be empty)
}
```
### Optional Fields
```json
{
"timestamp": "...", // Optional: when saved
"userQuestion": "..." // Optional: user question text
}
```
### Data Source Object
```json
{
"label": "string", // Required: reference name
"content": "string" // Required: content (can be empty)
}
```
### Agent Object
```json
{
"title": "string", // Required: agent name
"prompt": "string", // Required: prompt template
"model": "string", // Required: model name
"subscribeTopic": "string", // Required: topic to listen to
"publishTopic": "string", // Optional: topic to publish to (can be null/empty)
"showResult": boolean // Required: whether to show in results
}
```
## Advanced Usage
### Programmatic Config Generation
Generate configs programmatically:
```python
import json
config = {
"version": "1.0",
"timestamp": "2026-02-01T10:00:00Z",
"dataSources": [
{"label": "Schema", "content": load_schema_from_db()},
{"label": "Rules", "content": load_business_rules()}
],
"agents": [
{
"title": "SQL Generator",
"prompt": "...",
"model": "phi4-mini",
"subscribeTopic": "START",
"publishTopic": "SQL",
"showResult": True
}
]
}
with open('auto-generated-config.json', 'w') as f:
json.dump(config, f, indent=2)
```
### Config Validation Script
Validate configs before loading:
```python
import json
def validate_config(filepath):
with open(filepath) as f:
config = json.load(f)
# Check required fields
assert "version" in config
assert "dataSources" in config
assert "agents" in config
# Validate data sources
for ds in config["dataSources"]:
assert "label" in ds
assert "content" in ds
# Validate agents
for agent in config["agents"]:
assert "title" in agent
assert "prompt" in agent
assert "model" in agent
assert "subscribeTopic" in agent
assert "showResult" in agent
print(f"✓ Config is valid: {len(config['dataSources'])} data sources, {len(config['agents'])} agents")
validate_config("my-config.json")
```
### Merge Configs
Combine multiple configs:
```python
import json
def merge_configs(config1_path, config2_path, output_path):
with open(config1_path) as f1, open(config2_path) as f2:
c1 = json.load(f1)
c2 = json.load(f2)
merged = {
"version": "1.0",
"dataSources": c1["dataSources"] + c2["dataSources"],
"agents": c1["agents"] + c2["agents"],
"userQuestion": c1.get("userQuestion", "")
}
with open(output_path, 'w') as f:
json.dump(merged, f, indent=2)
merge_configs("pipeline-a.json", "pipeline-b.json", "merged-pipeline.json")
```
## Troubleshooting
### Issue: "Invalid configuration file"
**Cause**: File format is incorrect
**Solution**:
1. Open file in text editor
2. Verify it's valid JSON
3. Check required fields exist
### Issue: Data sources empty after load
**Cause**: Content wasn't saved
**Solution**: Check original file has "content" fields populated
### Issue: Agents not working after load
**Cause**: Model might not be available
**Solution**: Check agent "model" field matches available models (phi4-mini, cniongolo/biomistral)
### Issue: Topics not matching after load
**Cause**: Topic names might have changed
**Solution**: Topics are case-insensitive now, but check for typos
## Tips
1. **Always test after loading**: Execute pipeline to verify everything works
2. **Keep configs small**: Separate large data sources into multiple configs
3. **Use version control**: Track configs in Git for history
4. **Document changes**: Add comments in data source content
5. **Share wisely**: Remove sensitive data before sharing configs
|