|
| 1 | +import platform |
| 2 | +from typing import Any |
| 3 | + |
| 4 | +# Strands tools |
| 5 | +from strands_tools import ( |
| 6 | + agent_graph, |
| 7 | + calculator, |
| 8 | + cron, |
| 9 | + current_time, |
| 10 | + editor, |
| 11 | + environment, |
| 12 | + file_read, |
| 13 | + file_write, |
| 14 | + generate_image, |
| 15 | + http_request, |
| 16 | + image_reader, |
| 17 | + journal, |
| 18 | + load_tool, |
| 19 | + memory, |
| 20 | + nova_reels, |
| 21 | + retrieve, |
| 22 | + slack, |
| 23 | + speak, |
| 24 | + stop, |
| 25 | + swarm, |
| 26 | + think, |
| 27 | + use_aws, |
| 28 | + use_llm, |
| 29 | + workflow, |
| 30 | +) |
| 31 | + |
| 32 | +# Custom tools |
| 33 | +from tools import ( |
| 34 | + store_in_kb, |
| 35 | + strand, |
| 36 | + welcome, |
| 37 | +) |
| 38 | + |
| 39 | + |
| 40 | +def get_tools() -> dict[str, Any]: |
| 41 | + """ |
| 42 | + Returns the platform-specific collection of available agent tools for strands. |
| 43 | +
|
| 44 | + Note: |
| 45 | + Tool availability varies by platform and system configuration. |
| 46 | + Each tool is initialized as a singleton instance. |
| 47 | + """ |
| 48 | + |
| 49 | + tools = { |
| 50 | + "agent_graph": agent_graph, |
| 51 | + "calculator": calculator, |
| 52 | + "cron": cron, |
| 53 | + "current_time": current_time, |
| 54 | + "editor": editor, |
| 55 | + "environment": environment, |
| 56 | + "file_read": file_read, |
| 57 | + "file_write": file_write, |
| 58 | + "generate_image": generate_image, |
| 59 | + "http_request": http_request, |
| 60 | + "image_reader": image_reader, |
| 61 | + "journal": journal, |
| 62 | + "load_tool": load_tool, |
| 63 | + "memory": memory, |
| 64 | + "nova_reels": nova_reels, |
| 65 | + "retrieve": retrieve, |
| 66 | + "slack": slack, |
| 67 | + "speak": speak, |
| 68 | + "stop": stop, |
| 69 | + "swarm": swarm, |
| 70 | + "think": think, |
| 71 | + "use_aws": use_aws, |
| 72 | + "use_llm": use_llm, |
| 73 | + "workflow": workflow, |
| 74 | + # Strands tools |
| 75 | + "store_in_kb": store_in_kb, |
| 76 | + "strand": strand, |
| 77 | + "welcome": welcome, |
| 78 | + } |
| 79 | + |
| 80 | + # Some tools don't currently work on windows and even fail to import, so we need to dynamically add these |
| 81 | + # (https://github.com/strands-agents/tools/issues/17 |
| 82 | + if platform.system() != "Windows": |
| 83 | + from strands_tools import ( |
| 84 | + python_repl, |
| 85 | + shell, |
| 86 | + ) |
| 87 | + |
| 88 | + tools |= { |
| 89 | + "python_repl": python_repl, |
| 90 | + "shell": shell, |
| 91 | + } |
| 92 | + |
| 93 | + return tools |
0 commit comments