Skip to content

Commit 26947c6

Browse files
committed
feat: adding diagram tool
1 parent d1de6cf commit 26947c6

File tree

4 files changed

+2026
-3
lines changed

4 files changed

+2026
-3
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Strands Agents Tools is a community-driven project that provides a powerful set
5454
- 🐝 **Swarm Intelligence** - Coordinate multiple AI agents for parallel problem solving with shared memory
5555
- 🔄 **Multiple tools in Parallel** - Call multiple other tools at the same time in parallel with Batch Tool
5656
- 🔍 **Browser Tool** - Tool giving an agent access to perform automated actions on a browser (chromium)
57+
- 📈 **Diagram** - Create AWS cloud diagrams, basic diagrams, or UML diagrams using python libraries
5758

5859
## 📦 Installation
5960

@@ -128,6 +129,7 @@ Below is a comprehensive table of all available tools, how to use them with an a
128129
| workflow | `agent.tool.workflow(action="create", name="data_pipeline", steps=[{"tool": "file_read"}, {"tool": "python_repl"}])` | Define, execute, and manage multi-step automated workflows |
129130
| batch| `agent.tool.batch(invocations=[{"name": "current_time", "arguments": {"timezone": "Europe/London"}}, {"name": "stop", "arguments": {}}])` | Call multiple other tools in parallel. |
130131
| browser | `browser = LocalChromiumBrowser(); agent = Agent(tools=[browser.browser])` | Web scraping, automated testing, form filling, web automation tasks |
132+
| diagram | `agent.tool.diagram(diagram_type="cloud", nodes=[{"id": "s3", "type": "S3"}], edges=[])` | Create AWS cloud architecture diagrams, network diagrams, graphs, and UML diagrams (all 14 types) |
131133

132134
\* *These tools do not work on windows*
133135

@@ -450,6 +452,55 @@ response = agent("discover available agents and send a greeting message")
450452
# - send_message(message_text, target_agent_url) to communicate
451453
```
452454

455+
### Diagram
456+
457+
```python
458+
from strands import Agent
459+
from strands_tools import diagram
460+
461+
agent = Agent(tools=[diagram])
462+
463+
# Create an AWS cloud architecture diagram
464+
result = agent.tool.diagram(
465+
diagram_type="cloud",
466+
nodes=[
467+
{"id": "users", "type": "Users", "label": "End Users"},
468+
{"id": "cloudfront", "type": "CloudFront", "label": "CDN"},
469+
{"id": "s3", "type": "S3", "label": "Static Assets"},
470+
{"id": "api", "type": "APIGateway", "label": "API Gateway"},
471+
{"id": "lambda", "type": "Lambda", "label": "Backend Service"}
472+
],
473+
edges=[
474+
{"from": "users", "to": "cloudfront"},
475+
{"from": "cloudfront", "to": "s3"},
476+
{"from": "users", "to": "api"},
477+
{"from": "api", "to": "lambda"}
478+
],
479+
title="Web Application Architecture"
480+
)
481+
482+
# Create a UML class diagram
483+
result = agent.tool.diagram(
484+
diagram_type="class",
485+
elements=[
486+
{
487+
"name": "User",
488+
"attributes": ["+id: int", "-name: string", "#email: string"],
489+
"methods": ["+login(): bool", "+logout(): void"]
490+
},
491+
{
492+
"name": "Order",
493+
"attributes": ["+id: int", "-items: List", "-total: float"],
494+
"methods": ["+addItem(item): void", "+calculateTotal(): float"]
495+
}
496+
],
497+
relationships=[
498+
{"from": "User", "to": "Order", "type": "association", "multiplicity": "1..*"}
499+
],
500+
title="E-commerce Domain Model"
501+
)
502+
```
503+
453504
## 🌍 Environment Variables Configuration
454505

455506
Agents Tools provides extensive customization through environment variables. This allows you to configure tool behavior without modifying code, making it ideal for different environments (development, testing, production).

pyproject.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ agent_core_code_interpreter = [
9191
"bedrock-agentcore==0.1.0"
9292
]
9393
a2a_client = ["a2a-sdk[sql]>=0.2.11"]
94+
diagram = [
95+
"matplotlib>=3.5.0,<4.0.0",
96+
"graphviz>=0.20.0,<1.0.0",
97+
"networkx>=2.8.0,<4.0.0",
98+
"diagrams>=0.23.0,<1.0.0",
99+
]
94100

95101
[tool.hatch.envs.hatch-static-analysis]
96-
features = ["mem0_memory", "local_chromium_browser", "agent_core_browser", "agent_core_code_interpreter", "a2a_client"]
102+
features = ["mem0_memory", "local_chromium_browser", "agent_core_browser", "agent_core_code_interpreter", "a2a_client", "diagram"]
97103
dependencies = [
98104
"strands-agents>=1.0.0",
99105
"mypy>=0.981,<1.0.0",
@@ -112,7 +118,7 @@ lint-check = [
112118
lint-fix = ["ruff check --fix"]
113119

114120
[tool.hatch.envs.hatch-test]
115-
features = ["mem0_memory", "local_chromium_browser", "agent_core_browser", "agent_core_code_interpreter", "a2a_client"]
121+
features = ["mem0_memory", "local_chromium_browser", "agent_core_browser", "agent_core_code_interpreter", "a2a_client", "diagram"]
116122
extra-dependencies = [
117123
"moto>=5.1.0,<6.0.0",
118124
"pytest>=8.0.0,<9.0.0",
@@ -196,4 +202,4 @@ name = "cz_conventional_commits"
196202
tag_format = "v$version"
197203
bump_message = "chore(release): bump version $current_version -> $new_version"
198204
version_files = ["pyproject.toml:version"]
199-
update_changelog_on_bump = true
205+
update_changelog_on_bump = true

0 commit comments

Comments
 (0)