From a945a697e776c4208830eae7252ea3cf587903b0 Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Wed, 11 Jun 2025 21:01:32 +0530 Subject: [PATCH] Add visualizer docs --- docs/mkdocs.yml | 4 ++++ docs/swarms/utils/index.md | 7 ++++++ docs/swarms/utils/visualizer.md | 42 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 docs/swarms/utils/index.md create mode 100644 docs/swarms/utils/visualizer.md diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index d4e9725c..2223be5c 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -274,6 +274,10 @@ nav: - Social Media: - Twitter: "swarms_tools/twitter.md" + - Swarms Utilities: + - Overview: "swarms/utils/index.md" + - Visualizer: "swarms/utils/visualizer.md" + - Swarms Memory: - Overview: "swarms_memory/index.md" - Memory Systems: diff --git a/docs/swarms/utils/index.md b/docs/swarms/utils/index.md new file mode 100644 index 00000000..7a11a857 --- /dev/null +++ b/docs/swarms/utils/index.md @@ -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. diff --git a/docs/swarms/utils/visualizer.md b/docs/swarms/utils/visualizer.md new file mode 100644 index 00000000..e5a6ad32 --- /dev/null +++ b/docs/swarms/utils/visualizer.md @@ -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** – per‑device 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.