diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index b726465c6..9bdcdca89 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -188,6 +188,7 @@ nav: - Philosophy: "swarms/concept/philosophy.md" - Changelog: - Swarms 5.6.8: "swarms/changelog/5_6_8.md" + - Swarms 5.8.1: "swarms/changelog/5_8_1.md" - Swarm Models: - Overview: "swarms/models/index.md" - How to Create A Custom Language Model: "swarms/models/custom_model.md" diff --git a/docs/swarms/changelog/5_8_1.md b/docs/swarms/changelog/5_8_1.md new file mode 100644 index 000000000..5d6d7b77e --- /dev/null +++ b/docs/swarms/changelog/5_8_1.md @@ -0,0 +1,119 @@ +# Swarms 5.8.1 Feature Documentation + +## 1. Enhanced Command Line Interface (CLI) + +### 1.1 Integrated Onboarding Process + +```bash +$ swarms onboarding +``` + +### 1.2 Run Agents Command + +```bash +$ swarms run-agents --yaml-file agents.yaml +``` + +This command allows users to execute multiple agents defined in a YAML file. Here's the process: + +1. The command reads the specified YAML file (`agents.yaml` in this case). +2. It parses the YAML content, extracting the configuration for each agent. +3. For each agent defined in the YAML: + - It creates an instance of the agent with the specified parameters. + - It sets up the agent's environment (model, temperature, max tokens, etc.). + - It assigns the given task to the agent. + - It executes the agent, respecting parameters like `max_loops`, `autosave`, and `verbose`. +4. The results from all agents are collected and presented to the user. + +The YAML file structure allows users to define multiple agents with different configurations, making it easy to run complex, multi-agent tasks from the command line. + +### 1.3 Generate Prompt Feature + +```bash +$ swarms generate-prompt --prompt "Create a marketing strategy for a new product launch" +``` + +This feature leverages Swarms' language model to generate expanded or refined prompts: + +1. The command takes the user's input prompt as a starting point. +2. It likely sends this prompt to a pre-configured language model (possibly GPT-4 or a similar model). +3. The model then generates an expanded or more detailed version of the prompt. +4. The generated prompt is returned to the user, possibly with options to further refine or save it. + +This feature can help users create more effective prompts for their agents or other AI tasks. + +## 2. New Prompt Management System + +### 2.1 Prompt Class + +The new `Prompt` class provides a robust system for managing and versioning prompts: + +```python +from swarms import Prompt + +marketing_prompt = Prompt(content="Initial marketing strategy draft", autosave=True) + +print(marketing_prompt.get_prompt()) +``` + +Key features of the `Prompt` class: + +1. **Initialization**: The class is initialized with initial content and an `autosave` option. + +2. **Editing**: + ```python + marketing_prompt.edit_prompt("Updated marketing strategy with social media focus") + ``` + This method updates the prompt content and, if `autosave` is True, automatically saves the new version. + +3. **Retrieval**: + ```python + current_content = marketing_prompt.get_prompt() + ``` + This method returns the current content of the prompt. + +4. **Version History**: + ```python + print(f"Edit history: {marketing_prompt.edit_history}") + ``` + The class maintains a history of edits, allowing users to track changes over time. + +5. **Rollback**: + ```python + marketing_prompt.rollback(1) + ``` + This feature allows users to revert to a previous version of the prompt. + +6. **Duplicate Prevention**: + The class includes logic to prevent duplicate edits, raising a `ValueError` if an attempt is made to save the same content twice in a row. + +This system provides a powerful way to manage prompts, especially for complex projects where prompt engineering and iteration are crucial. + +## 3. Upcoming Features Preview + +### 3.1 Enhanced Agent Execution Capabilities + +The preview code demonstrates planned enhancements for agent execution: + +```python +from swarms import Agent, ExecutionEnvironment + +my_agent = Agent(name="data_processor") + +cpu_env = ExecutionEnvironment(type="cpu", cores=4) +my_agent.run(environment=cpu_env) + +gpu_env = ExecutionEnvironment(type="gpu", device_id=0) +my_agent.run(environment=gpu_env) + +fractional_env = ExecutionEnvironment(type="fractional", cpu_fraction=0.5, gpu_fraction=0.3) +my_agent.run(environment=fractional_env) +``` + +This upcoming feature will allow for more fine-grained control over the execution environment: + +1. **CPU Execution**: Users can specify the number of CPU cores to use. +2. **GPU Execution**: Allows selection of a specific GPU device. +3. **Fractionalized Execution**: Enables partial allocation of CPU and GPU resources. + +These features will provide users with greater flexibility in resource allocation, potentially improving performance and allowing for more efficient use of available hardware. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d858d2abd..84d0e7cf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "5.7.8" +version = "5.8.1" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/cli/main.py b/swarms/cli/main.py index cd0b4f6b5..3bcd984bd 100644 --- a/swarms/cli/main.py +++ b/swarms/cli/main.py @@ -9,7 +9,7 @@ create_agents_from_yaml, ) from swarms.agents.cli_prompt_generator_func import generate_prompt - +import subprocess console = Console() @@ -44,6 +44,7 @@ def show_help(): [bold white]read-docs[/bold white] : Redirects you to swarms cloud documentation! [bold white]run-agents[/bold white] : Run your Agents from your specified yaml file. Specify the yaml file with path the `--yaml-file` arg. Example: `--yaml-file agents.yaml` [bold white]generate-prompt[/bold white] : Generate a prompt through automated prompt engineering. Requires an OPENAI Key in your `.env` Example: --prompt "Generate a prompt for an agent to analyze legal docs" + [bold white]auto-upgrade[/bold white] : Automatically upgrades Swarms to the latest version For more details, visit: https://docs.swarms.world """ @@ -100,6 +101,29 @@ def check_login(): with open(cache_file, "w") as f: f.write("logged_in") console.print("[bold green]Login successful![/bold green]") + +def check_and_upgrade_version(): + console.print("[bold yellow]Checking for Swarms updates...[/bold yellow]") + try: + # Check for updates using pip + result = subprocess.run( + ["pip", "list", "--outdated", "--format=freeze"], + capture_output=True, + text=True + ) + outdated_packages = result.stdout.splitlines() + + # Check if Swarms is outdated + for package in outdated_packages: + if package.startswith("swarms=="): + console.print("[bold magenta]New version available! Upgrading...[/bold magenta]") + subprocess.run(["pip", "install", "--upgrade", "swarms"], check=True) + console.print("[bold green]Swarms upgraded successfully![/bold green]") + return + + console.print("[bold green]Swarms is up-to-date.[/bold green]") + except Exception as e: + console.print(f"[bold red]Error checking for updates: {e}[/bold red]") # Main CLI handler @@ -116,6 +140,7 @@ def main(): "check-login", "run-agents", "generate-prompt", # Added new command for generating prompts + "auto-upgrade", # Added new command for auto-upgrade ], help="Command to run", ) @@ -165,17 +190,19 @@ def main(): yaml_file=args.yaml_file, return_type="tasks" ) elif args.command == "generate-prompt": - if args.prompt_task: + if args.prompt: # Corrected from args.prompt_task to args.prompt generate_prompt( num_loops=args.num_loops, autosave=args.autosave, save_to_yaml=args.save_to_yaml, - prompt=args.prompt_task, + prompt=args.prompt, # Corrected from args.prompt_task to args.prompt ) else: console.print( - "[bold red]Please specify a task for generating a prompt using '--prompt-task'.[/bold red]" + "[bold red]Please specify a task for generating a prompt using '--prompt'.[/bold red]" ) + elif args.command == "auto-upgrade": + check_and_upgrade_version() else: console.print( "[bold red]Unknown command! Type 'help' for usage.[/bold red]"