Add visualizer docs

pull/877/head^2
Pavan Kumar 2 months ago
parent 56cd9aa1c5
commit a945a697e7

@ -274,6 +274,10 @@ nav:
- Social Media: - Social Media:
- Twitter: "swarms_tools/twitter.md" - Twitter: "swarms_tools/twitter.md"
- Swarms Utilities:
- Overview: "swarms/utils/index.md"
- Visualizer: "swarms/utils/visualizer.md"
- Swarms Memory: - Swarms Memory:
- Overview: "swarms_memory/index.md" - Overview: "swarms_memory/index.md"
- Memory Systems: - Memory Systems:

@ -0,0 +1,7 @@
# Swarms Utilities
The `swarms.utils` package provides small helper modules that simplify common tasks throughout the framework. These utilities range from data formatting helpers to system monitoring tools.
## Available Guides
- [Visualizer](visualizer.md) real-time dashboard for agent output and resource usage.

@ -0,0 +1,42 @@
# Visualizer Utility
`SwarmVisualizationRich` is a live dashboard built with Rich that lets you watch agents work while monitoring system resources.
## Starting the Visualizer
```python
from swarms.utils.visualizer import SwarmVisualizationRich, SwarmMetadata
from swarms import Agent
# create agents
agent = Agent(name="DemoAgent")
metadata = SwarmMetadata(name="Demo Swarm", description="Example swarm")
viz = SwarmVisualizationRich(swarm_metadata=metadata, agents=[agent])
import asyncio
asyncio.run(viz.start())
```
The `start()` method runs an asynchronous event loop that continually refreshes the console layout.
## CPU and GPU Metrics
When `update_resources=True`, the visualizer displays current CPU core count, memory usage, and GPU utilization. GPU statistics rely on `pynvml`; if no GPU is found the panel shows `No GPU detected`.
- **CPU** logical core count returned by `psutil.cpu_count()`.
- **Memory** used/total RAM with percentage from `psutil.virtual_memory()`.
- **GPU** perdevice memory consumption via NVIDIA's NVML.
## Embedding in Custom Workflows
You can stream agent output into the visualizer from any workflow:
```python
viz.log_agent_output(agent, "Task started...")
result = await some_coroutine()
viz.log_agent_output(agent, f"Result: {result}")
```
Combine this with your swarms or structured workflows to obtain a live view of progress and system health.
Loading…
Cancel
Save