From ef41e7e98ce717f0ca1fad5a815424751bb2aa1f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 12 Oct 2024 23:41:22 -0400 Subject: [PATCH] [EXAMPLES CLEANUP] --- README.md | 1 + .../{ => experimental}/swarm_architecture_examples.py | 0 .../structs/swarms/{ => rearrange}/rag_with_codebase.py | 0 .../structs/swarms/{ => sequential}/automate_docs.py | 0 .../structs/swarms/{ => sequential}/example_logistics.py | 0 swarms/structs/swarm_router.py | 9 ++++++++- 6 files changed, 9 insertions(+), 1 deletion(-) rename examples/structs/swarms/{ => experimental}/swarm_architecture_examples.py (100%) rename examples/structs/swarms/{ => rearrange}/rag_with_codebase.py (100%) rename examples/structs/swarms/{ => sequential}/automate_docs.py (100%) rename examples/structs/swarms/{ => sequential}/example_logistics.py (100%) diff --git a/README.md b/README.md index 8aa2521c..a0b44bb4 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Swarms is an enterprise grade and production ready multi-agent collaboration fra - `$ pip install -U swarms` And, don't forget to install swarms! - `.env` file with API keys from your providers like `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` - Set an `.env` Variable with your desired workspace dir: `WORKSPACE_DIR="agent_workspace"` or do it in your terminal with `export WORKSPACE_DIR="agent_workspace"` +- Finally, `swarms onboarding` to get you started. ## Onboarding Refer to our documentation for production grade implementation details. diff --git a/examples/structs/swarms/swarm_architecture_examples.py b/examples/structs/swarms/experimental/swarm_architecture_examples.py similarity index 100% rename from examples/structs/swarms/swarm_architecture_examples.py rename to examples/structs/swarms/experimental/swarm_architecture_examples.py diff --git a/examples/structs/swarms/rag_with_codebase.py b/examples/structs/swarms/rearrange/rag_with_codebase.py similarity index 100% rename from examples/structs/swarms/rag_with_codebase.py rename to examples/structs/swarms/rearrange/rag_with_codebase.py diff --git a/examples/structs/swarms/automate_docs.py b/examples/structs/swarms/sequential/automate_docs.py similarity index 100% rename from examples/structs/swarms/automate_docs.py rename to examples/structs/swarms/sequential/automate_docs.py diff --git a/examples/structs/swarms/example_logistics.py b/examples/structs/swarms/sequential/example_logistics.py similarity index 100% rename from examples/structs/swarms/example_logistics.py rename to examples/structs/swarms/sequential/example_logistics.py diff --git a/swarms/structs/swarm_router.py b/swarms/structs/swarm_router.py index 60306bce..053ae5db 100644 --- a/swarms/structs/swarm_router.py +++ b/swarms/structs/swarm_router.py @@ -79,8 +79,15 @@ class SwarmRouter: **kwargs: Arbitrary keyword arguments. Raises: - ValueError: If an invalid swarm type is provided. + ValueError: If an invalid swarm type is provided, or if there are no agents, or if swarm type is "none", or if max_loops is 0. """ + if not agents: + raise ValueError("No agents provided for the swarm.") + if swarm_type is None: + raise ValueError("Swarm type cannot be 'none'.") + if max_loops == 0: + raise ValueError("max_loops cannot be 0.") + self.name = name self.description = description self.max_loops = max_loops