diff --git a/docs/swarms/structs/forest_swarm.md b/docs/swarms/structs/forest_swarm.md index 3e1f0de9..3aab358a 100644 --- a/docs/swarms/structs/forest_swarm.md +++ b/docs/swarms/structs/forest_swarm.md @@ -71,6 +71,55 @@ The architecture allows for efficient task assignment by selecting the most rele ## Full Code Example +```python +from swarms.structs.tree_swarm import TreeAgent, Tree, ForestSwarm +# Example Usage: + +# Create agents with varying system prompts and dynamically generated distances/keywords +agents_tree1 = [ + TreeAgent( + system_prompt="Stock Analysis Agent", + agent_name="Stock Analysis Agent", + ), + TreeAgent( + system_prompt="Financial Planning Agent", + agent_name="Financial Planning Agent", + ), + TreeAgent( + agent_name="Retirement Strategy Agent", + system_prompt="Retirement Strategy Agent", + ), +] + +agents_tree2 = [ + TreeAgent( + system_prompt="Tax Filing Agent", + agent_name="Tax Filing Agent", + ), + TreeAgent( + system_prompt="Investment Strategy Agent", + agent_name="Investment Strategy Agent", + ), + TreeAgent( + system_prompt="ROTH IRA Agent", agent_name="ROTH IRA Agent" + ), +] + +# Create trees +tree1 = Tree(tree_name="Financial Tree", agents=agents_tree1) +tree2 = Tree(tree_name="Investment Tree", agents=agents_tree2) + +# Create the ForestSwarm +multi_agent_structure = ForestSwarm(trees=[tree1, tree2]) + +# Run a task +task = "Our company is incorporated in delaware, how do we do our taxes for free?" +output = multi_agent_structure.run(task) +print(output) +``` + + + --- ## Example Workflow