From f2dc945183ef5b92af7ffabe75fdb32f1fd4c7d8 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Mon, 24 Nov 2025 01:16:05 -0800 Subject: [PATCH] [CLI][Examples][CLI Docs] --- examples/README.md | 32 ++++- examples/cli/01_setup_check.sh | 7 + examples/cli/02_onboarding.sh | 7 + examples/cli/03_get_api_key.sh | 7 + examples/cli/04_check_login.sh | 7 + examples/cli/05_create_agent.sh | 12 ++ examples/cli/06_run_agents_yaml.sh | 7 + examples/cli/07_load_markdown.sh | 7 + examples/cli/08_llm_council.sh | 7 + examples/cli/09_heavy_swarm.sh | 7 + examples/cli/10_autoswarm.sh | 7 + examples/cli/11_features.sh | 7 + examples/cli/12_help.sh | 7 + examples/cli/13_auto_upgrade.sh | 7 + examples/cli/14_book_call.sh | 7 + examples/cli/README.md | 197 +++++++++++++++++++++++++++++ examples/cli/run_all_examples.sh | 11 ++ 17 files changed, 336 insertions(+), 7 deletions(-) create mode 100644 examples/cli/01_setup_check.sh create mode 100644 examples/cli/02_onboarding.sh create mode 100644 examples/cli/03_get_api_key.sh create mode 100644 examples/cli/04_check_login.sh create mode 100644 examples/cli/05_create_agent.sh create mode 100644 examples/cli/06_run_agents_yaml.sh create mode 100644 examples/cli/07_load_markdown.sh create mode 100644 examples/cli/08_llm_council.sh create mode 100644 examples/cli/09_heavy_swarm.sh create mode 100644 examples/cli/10_autoswarm.sh create mode 100644 examples/cli/11_features.sh create mode 100644 examples/cli/12_help.sh create mode 100644 examples/cli/13_auto_upgrade.sh create mode 100644 examples/cli/14_book_call.sh create mode 100644 examples/cli/README.md create mode 100644 examples/cli/run_all_examples.sh diff --git a/examples/README.md b/examples/README.md index 34259fd4..ac908c7a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -79,16 +79,26 @@ This directory contains comprehensive examples demonstrating various capabilitie - [README.md](ui/README.md) - UI examples documentation - [chat.py](ui/chat.py) - Chat interface example +### Command Line Interface + +- **[cli/](cli/)** - CLI command examples demonstrating all available Swarms CLI features including setup, agent management, multi-agent architectures, and utilities. + - [README.md](cli/README.md) - CLI examples documentation + - [01_setup_check.sh](cli/01_setup_check.sh) - Environment setup verification + - [05_create_agent.sh](cli/05_create_agent.sh) - Create custom agents + - [08_llm_council.sh](cli/08_llm_council.sh) - LLM Council collaboration + - [09_heavy_swarm.sh](cli/09_heavy_swarm.sh) - HeavySwarm complex analysis + ## Quick Start 1. **New to Swarms?** Start with [single_agent/simple_agent.py](single_agent/simple_agent.py) for basic concepts -2. **Want multi-agent workflows?** Check out [multi_agent/duo_agent.py](multi_agent/duo_agent.py) -3. **Need tool integration?** Explore [tools/agent_as_tools.py](tools/agent_as_tools.py) -4. **Interested in AOP?** Try [aop_examples/client/example_new_agent_tools.py](aop_examples/client/example_new_agent_tools.py) for agent discovery -5. **Want to see social algorithms?** Check out [multi_agent/social_algorithms_examples/](multi_agent/social_algorithms_examples/) -6. **Looking for guides?** Visit [guides/](guides/) for comprehensive tutorials -7. **Need RAG?** Try [rag/qdrant_rag_example.py](rag/qdrant_rag_example.py) -8. **Want reasoning agents?** Check out [reasoning_agents/example_o3.py](reasoning_agents/example_o3.py) +2. **Want to use the CLI?** Check out [cli/](cli/) for all CLI command examples +3. **Want multi-agent workflows?** Check out [multi_agent/duo_agent.py](multi_agent/duo_agent.py) +4. **Need tool integration?** Explore [tools/agent_as_tools.py](tools/agent_as_tools.py) +5. **Interested in AOP?** Try [aop_examples/client/example_new_agent_tools.py](aop_examples/client/example_new_agent_tools.py) for agent discovery +6. **Want to see social algorithms?** Check out [multi_agent/social_algorithms_examples/](multi_agent/social_algorithms_examples/) +7. **Looking for guides?** Visit [guides/](guides/) for comprehensive tutorials +8. **Need RAG?** Try [rag/qdrant_rag_example.py](rag/qdrant_rag_example.py) +9. **Want reasoning agents?** Check out [reasoning_agents/example_o3.py](reasoning_agents/example_o3.py) ## Key Examples by Category @@ -122,6 +132,14 @@ This directory contains comprehensive examples demonstrating various capabilitie - [Azure](single_agent/llms/azure_agent.py) - Azure OpenAI - [Ollama](models/simple_example_ollama.py) - Local Ollama models +### CLI Examples + +- [Setup Check](cli/01_setup_check.sh) - Verify environment setup +- [Create Agent](cli/05_create_agent.sh) - Create custom agents via CLI +- [LLM Council](cli/08_llm_council.sh) - Run LLM Council collaboration +- [HeavySwarm](cli/09_heavy_swarm.sh) - Run HeavySwarm for complex tasks +- [All CLI Examples](cli/) - Complete CLI examples directory + ## Documentation Each subdirectory contains its own README.md file with detailed descriptions and links to all available examples. Click on any folder above to explore its specific examples and use cases. diff --git a/examples/cli/01_setup_check.sh b/examples/cli/01_setup_check.sh new file mode 100644 index 00000000..523c806a --- /dev/null +++ b/examples/cli/01_setup_check.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Setup Check Example +# Verify your Swarms environment setup + +swarms setup-check + diff --git a/examples/cli/02_onboarding.sh b/examples/cli/02_onboarding.sh new file mode 100644 index 00000000..973a5630 --- /dev/null +++ b/examples/cli/02_onboarding.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Onboarding Example +# Start the interactive onboarding process + +swarms onboarding + diff --git a/examples/cli/03_get_api_key.sh b/examples/cli/03_get_api_key.sh new file mode 100644 index 00000000..f9775413 --- /dev/null +++ b/examples/cli/03_get_api_key.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Get API Key Example +# Open API key portal in browser + +swarms get-api-key + diff --git a/examples/cli/04_check_login.sh b/examples/cli/04_check_login.sh new file mode 100644 index 00000000..41479137 --- /dev/null +++ b/examples/cli/04_check_login.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Check Login Example +# Verify authentication status + +swarms check-login + diff --git a/examples/cli/05_create_agent.sh b/examples/cli/05_create_agent.sh new file mode 100644 index 00000000..eb4ed597 --- /dev/null +++ b/examples/cli/05_create_agent.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Swarms CLI - Create Agent Example +# Create and run a custom agent + +swarms agent \ + --name "Research Agent" \ + --description "AI research specialist" \ + --system-prompt "You are an expert research agent." \ + --task "Analyze current trends in renewable energy" \ + --model-name "gpt-4o-mini" + diff --git a/examples/cli/06_run_agents_yaml.sh b/examples/cli/06_run_agents_yaml.sh new file mode 100644 index 00000000..1856c54f --- /dev/null +++ b/examples/cli/06_run_agents_yaml.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Run Agents from YAML Example +# Execute agents from YAML configuration file + +swarms run-agents --yaml-file agents.yaml + diff --git a/examples/cli/07_load_markdown.sh b/examples/cli/07_load_markdown.sh new file mode 100644 index 00000000..b1ba6e56 --- /dev/null +++ b/examples/cli/07_load_markdown.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Load Markdown Agents Example +# Load agents from markdown files + +swarms load-markdown --markdown-path ./agents/ + diff --git a/examples/cli/08_llm_council.sh b/examples/cli/08_llm_council.sh new file mode 100644 index 00000000..eb29b726 --- /dev/null +++ b/examples/cli/08_llm_council.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - LLM Council Example +# Run LLM Council for collaborative problem-solving + +swarms llm-council --task "What are the best energy ETFs to invest in right now?" + diff --git a/examples/cli/09_heavy_swarm.sh b/examples/cli/09_heavy_swarm.sh new file mode 100644 index 00000000..6dfadc00 --- /dev/null +++ b/examples/cli/09_heavy_swarm.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - HeavySwarm Example +# Run HeavySwarm for complex task analysis + +swarms heavy-swarm --task "Analyze current market trends for renewable energy investments" + diff --git a/examples/cli/10_autoswarm.sh b/examples/cli/10_autoswarm.sh new file mode 100644 index 00000000..b94192f0 --- /dev/null +++ b/examples/cli/10_autoswarm.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Autoswarm Example +# Auto-generate swarm configuration + +swarms autoswarm --task "Analyze quarterly sales data" --model "gpt-4" + diff --git a/examples/cli/11_features.sh b/examples/cli/11_features.sh new file mode 100644 index 00000000..687200a4 --- /dev/null +++ b/examples/cli/11_features.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Features Example +# Display all available CLI features + +swarms features + diff --git a/examples/cli/12_help.sh b/examples/cli/12_help.sh new file mode 100644 index 00000000..09b6780c --- /dev/null +++ b/examples/cli/12_help.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Help Example +# Display comprehensive help documentation + +swarms help + diff --git a/examples/cli/13_auto_upgrade.sh b/examples/cli/13_auto_upgrade.sh new file mode 100644 index 00000000..6827f995 --- /dev/null +++ b/examples/cli/13_auto_upgrade.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Auto Upgrade Example +# Update Swarms to the latest version + +swarms auto-upgrade + diff --git a/examples/cli/14_book_call.sh b/examples/cli/14_book_call.sh new file mode 100644 index 00000000..e0108d9e --- /dev/null +++ b/examples/cli/14_book_call.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Swarms CLI - Book Call Example +# Schedule a strategy session + +swarms book-call + diff --git a/examples/cli/README.md b/examples/cli/README.md new file mode 100644 index 00000000..a002cd96 --- /dev/null +++ b/examples/cli/README.md @@ -0,0 +1,197 @@ +# Swarms CLI Examples + +This directory contains shell script examples demonstrating all available Swarms CLI commands and features. Each script is simple, focused, and demonstrates a single CLI command. + +## Quick Start + +All scripts are executable. Run them directly: + +```bash +chmod +x *.sh +./01_setup_check.sh +``` + +Or execute with bash: + +```bash +bash 01_setup_check.sh +``` + +## Available Examples + +### Setup & Configuration + +- **[01_setup_check.sh](examples/cli/01_setup_check.sh)** - Environment setup verification + ```bash + swarms setup-check + ``` + +- **[02_onboarding.sh](examples/cli/02_onboarding.sh)** - Interactive onboarding process + ```bash + swarms onboarding + ``` + +- **[03_get_api_key.sh](examples/cli/03_get_api_key.sh)** - Retrieve API keys + ```bash + swarms get-api-key + ``` + +- **[04_check_login.sh](examples/cli/04_check_login.sh)** - Verify authentication + ```bash + swarms check-login + ``` + +### Agent Management + +- **[05_create_agent.sh](examples/cli/05_create_agent.sh)** - Create and run custom agents + ```bash + swarms agent --name "Agent" --description "Description" --system-prompt "Prompt" --task "Task" + ``` + +- **[06_run_agents_yaml.sh](examples/cli/06_run_agents_yaml.sh)** - Execute agents from YAML + ```bash + swarms run-agents --yaml-file agents.yaml + ``` + +- **[07_load_markdown.sh](examples/cli/07_load_markdown.sh)** - Load agents from markdown files + ```bash + swarms load-markdown --markdown-path ./agents/ + ``` + +### Multi-Agent Architectures + +- **[08_llm_council.sh](examples/cli/08_llm_council.sh)** - Run LLM Council collaboration + ```bash + swarms llm-council --task "Your question here" + ``` + +- **[09_heavy_swarm.sh](examples/cli/09_heavy_swarm.sh)** - Run HeavySwarm for complex tasks + ```bash + swarms heavy-swarm --task "Your complex task here" + ``` + +- **[10_autoswarm.sh](examples/cli/10_autoswarm.sh)** - Auto-generate swarm configurations + ```bash + swarms autoswarm --task "Task description" --model "gpt-4" + ``` + +### Utilities + +- **[11_features.sh](examples/cli/11_features.sh)** - Display all available features + ```bash + swarms features + ``` + +- **[12_help.sh](examples/cli/12_help.sh)** - Display help documentation + ```bash + swarms help + ``` + +- **[13_auto_upgrade.sh](examples/cli/13_auto_upgrade.sh)** - Update Swarms package + ```bash + swarms auto-upgrade + ``` + +- **[14_book_call.sh](examples/cli/14_book_call.sh)** - Schedule strategy session + ```bash + swarms book-call + ``` + +### Run All Examples + +- **[run_all_examples.sh](examples/cli/run_all_examples.sh)** - Run multiple examples in sequence + ```bash + bash run_all_examples.sh + ``` + +## Script Structure + +Each script follows a simple pattern: + +1. **Shebang** - `#!/bin/bash` +2. **Comment** - Brief description of what the script does +3. **Single Command** - One CLI command execution + +Example: +```bash +#!/bin/bash + +# Swarms CLI - Setup Check Example +# Verify your Swarms environment setup + +swarms setup-check +``` + +## Usage Patterns + +### Basic Command Execution + +```bash +swarms [options] +``` + +### With Verbose Output + +```bash +swarms --verbose +``` + +### Environment Variables + +Set API keys before running scripts that require them: + +```bash +export OPENAI_API_KEY="your-key-here" +export ANTHROPIC_API_KEY="your-key-here" +export GOOGLE_API_KEY="your-key-here" +``` + +## Examples by Category + +### Setup & Diagnostics +- Environment setup verification +- Onboarding workflow +- API key management +- Authentication verification + +### Single Agent Operations +- Custom agent creation +- Agent configuration from YAML +- Agent loading from markdown + +### Multi-Agent Operations +- LLM Council for collaborative problem-solving +- HeavySwarm for complex analysis +- Auto-generated swarm configurations + +### Information & Help +- Feature discovery +- Help documentation +- Package management + +## File Paths + +All scripts are located in `examples/cli/`: + +- `examples/cli/01_setup_check.sh` +- `examples/cli/02_onboarding.sh` +- `examples/cli/03_get_api_key.sh` +- `examples/cli/04_check_login.sh` +- `examples/cli/05_create_agent.sh` +- `examples/cli/06_run_agents_yaml.sh` +- `examples/cli/07_load_markdown.sh` +- `examples/cli/08_llm_council.sh` +- `examples/cli/09_heavy_swarm.sh` +- `examples/cli/10_autoswarm.sh` +- `examples/cli/11_features.sh` +- `examples/cli/12_help.sh` +- `examples/cli/13_auto_upgrade.sh` +- `examples/cli/14_book_call.sh` +- `examples/cli/run_all_examples.sh` + +## Related Documentation + +- [CLI Reference](../../docs/swarms/cli/cli_reference.md) - Complete CLI documentation +- [Main Examples README](../README.md) - Other Swarms examples +- [Swarms Documentation](../../docs/) - Full Swarms documentation + diff --git a/examples/cli/run_all_examples.sh b/examples/cli/run_all_examples.sh new file mode 100644 index 00000000..ffd948e8 --- /dev/null +++ b/examples/cli/run_all_examples.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Swarms CLI - Run All Examples +# Run all CLI examples in sequence + +chmod +x *.sh + +swarms setup-check +swarms features +swarms help +