From 36279fba6abc1efb911fa425eef430d4474a13b6 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 25 Nov 2024 15:47:16 -0700 Subject: [PATCH 1/6] remove 3.9 from python packaging action --- .github/workflows/python-package.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 6e563af26..c0ad132e3 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,6 +1,8 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python +# [ ] TODO [pep 458](https://blog.pypi.org/posts/2024-11-14-pypi-now-supports-digital-attestations/) + name: Python package on: @@ -16,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 From 2e16d86465cd4923ccff00d3e9563030049749d9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Nov 2024 10:46:34 -0800 Subject: [PATCH 2/6] [CLEANUP] --- .gitignore | 3 ++- docs/swarms/install/install.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 89b0cdc7f..9f6e25b6b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,8 @@ audio/ video/ artifacts_three dataframe/ - +.ruff_cache +.pytest_cache static/generated runs Financial-Analysis-Agent_state.json diff --git a/docs/swarms/install/install.md b/docs/swarms/install/install.md index f69a09bdd..9d52d84e5 100644 --- a/docs/swarms/install/install.md +++ b/docs/swarms/install/install.md @@ -127,7 +127,7 @@ Before you begin, ensure you have the following installed: poetry install --extras "desktop" ``` -=== "Using Docker" +=== "Using Docker COMING SOON [DOES NOT WORK YET]" Docker is an excellent option for creating isolated and reproducible environments, suitable for both development and production. From 96ffec472d42e8143676ea6f746dae10cc98fd81 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Nov 2024 10:37:02 -0800 Subject: [PATCH 3/6] [DOCS] --- docs/assets/css/extra.css | 107 ++++++++++++++++++++++++++++++++++---- docs/mkdocs.yml | 2 + 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/docs/assets/css/extra.css b/docs/assets/css/extra.css index b639e2f7c..713feb4f2 100644 --- a/docs/assets/css/extra.css +++ b/docs/assets/css/extra.css @@ -1,18 +1,105 @@ +/* Root variables for primary colors */ +:root { + --md-primary-bg-color: #0d0d0d; /* Black background */ + --md-secondary-bg-color: #1a1a1a; /* Slightly lighter black */ + --md-accent-color: #FF073A; /* Neon red */ + --md-accent-color--hover: #FF2050; /* Bright neon red for hover */ + --md-text-color: #ffffff; /* White text */ + --md-code-bg-color: #121212; /* Darker background for code blocks */ + --md-code-border-color: #FF073A; /* Neon red border for code blocks */ + --md-link-color: var(--md-accent-color); +} -/* Further customization as needed */ +/* Apply background and text colors globally */ +body { + background-color: var(--md-primary-bg-color); + color: var(--md-text-color); +} +/* Headings with neon glow */ +h1, h2, h3, h4, h5, h6 { + color: var(--md-accent-color); + text-shadow: 0 0 5px var(--md-accent-color), 0 0 10px var(--md-accent-color); +} +/* Links with hover effects */ +a { + color: var(--md-link-color); + text-decoration: none; +} +a:hover { + color: var(--md-accent-color--hover); + text-shadow: 0 0 5px var(--md-accent-color--hover), 0 0 10px var(--md-accent-color--hover); +} + +/* Sidebar styling */ +.md-sidebar { + background-color: var(--md-secondary-bg-color); + border-right: 2px solid var(--md-accent-color); +} + +/* Navigation links in sidebar */ +.md-sidebar .md-nav__link { + color: var(--md-text-color); +} +.md-sidebar .md-nav__link:hover, +.md-sidebar .md-nav__link--active { + color: var(--md-accent-color); + background-color: var(--md-primary-bg-color); +} + +/* Code blocks with neon red accents */ +.md-typeset code { + background-color: var(--md-code-bg-color); + color: var(--md-text-color); + border: 1px solid var(--md-code-border-color); + border-radius: 4px; + padding: 2px 4px; + font-family: 'Fira Code', monospace; + text-shadow: 0 0 3px var(--md-code-border-color); +} + +/* Tables */ .md-typeset__table { - min-width: 100%; + min-width: 100%; + border-collapse: collapse; + background-color: var(--md-secondary-bg-color); + color: var(--md-text-color); +} +.md-typeset__table th, .md-typeset__table td { + border: 1px solid var(--md-accent-color); + padding: 8px; +} + +/* Buttons */ +button { + background-color: var(--md-accent-color); + color: var(--md-text-color); + border: none; + border-radius: 4px; + padding: 10px 15px; + cursor: pointer; + text-shadow: 0 0 5px var(--md-accent-color); +} +button:hover { + background-color: var(--md-accent-color--hover); } -.md-typeset table:not([class]) { - display: table; +/* Additional styling for search bar */ +.md-search__form { + background-color: var(--md-secondary-bg-color); + border: 1px solid var(--md-accent-color); +} +.md-search__input { + background-color: var(--md-primary-bg-color); + color: var(--md-text-color); } -/* -:root { - --md-primary-fg-color: #EE0F0F; - --md-primary-fg-color--light: #ECB7B7; - --md-primary-fg-color--dark: #90030C; - } */ \ No newline at end of file +/* Further customization */ +footer { + background-color: var(--md-secondary-bg-color); + color: var(--md-text-color); + text-align: center; + padding: 10px; + border-top: 2px solid var(--md-accent-color); +} diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 239588294..e11ff4bd4 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -63,12 +63,14 @@ theme: palette: - scheme: default primary: black + accent: red toggle: icon: material/brightness-7 name: Switch to dark mode # Palette toggle for dark mode - scheme: slate primary: black + accent: red toggle: icon: material/brightness-4 name: Switch to light mode From 0a51709dbe7352e05f5b169128ebe87384e910d6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Nov 2024 10:52:53 -0800 Subject: [PATCH 4/6] [DOCS] --- auto_swarm_builder.py | 2 -- docs/mkdocs.yml | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/auto_swarm_builder.py b/auto_swarm_builder.py index 8d981dda0..93e542fd4 100644 --- a/auto_swarm_builder.py +++ b/auto_swarm_builder.py @@ -1,5 +1,3 @@ -from loguru import logger - import os from typing import List diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index e11ff4bd4..9e5fc4abd 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -69,7 +69,7 @@ theme: name: Switch to dark mode # Palette toggle for dark mode - scheme: slate - primary: black + primary: white accent: red toggle: icon: material/brightness-4 @@ -82,6 +82,7 @@ theme: - navigation.expand - navigation.top - announce.dismiss + # Extensions markdown_extensions: - abbr From 1a8e305c29a5d4d422abeedc258b7d6c0a2162bb Mon Sep 17 00:00:00 2001 From: Occupying-Mars Date: Sun, 1 Dec 2024 01:03:19 +0530 Subject: [PATCH 5/6] import fixes --- README.md | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6469883d8..effb16804 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,13 @@ The `run` method is the primary entry point for executing tasks with an `Agent` ```python from swarms import Agent +from swarms.models import OpenAIChat + +model = OpenAIChat( + openai_api_key="your-api-key", + model_name="gpt-4o-mini", + temperature=0.1 +) agent = Agent( agent_name="Stock-Analysis-Agent", @@ -168,7 +175,7 @@ The `Agent` class offers a range of settings to tailor its behavior to specific ```python import os from swarms import Agent -from swarm_models import OpenAIChat +from swarms.models import OpenAIChat from swarms.prompts.finance_agent_sys_prompt import ( FINANCIAL_AGENT_SYS_PROMPT, @@ -231,7 +238,7 @@ graph TD ```python import os -from swarms_memory import ChromaDB +from swarms.memory import ChromaDB # Initialize the ChromaDB client for long-term memory management chromadb = ChromaDB( @@ -243,7 +250,7 @@ chromadb = ChromaDB( **Step 2: Define the Model** ```python -from swarm_models import Anthropic +from swarms.models import Anthropic from swarms.prompts.finance_agent_sys_prompt import ( FINANCIAL_AGENT_SYS_PROMPT, ) @@ -378,7 +385,7 @@ The following is an example of an agent that intakes a pydantic basemodel and ou ```python from pydantic import BaseModel, Field from swarms import Agent -from swarm_models import Anthropic +from swarms.models import OpenAIChat # Initialize the schema for the person's information @@ -410,7 +417,11 @@ agent = Agent( ), # Set the tool schema to the JSON string -- this is the key difference tool_schema=tool_schema, - llm=Anthropic(), + llm=OpenAIChat( + openai_api_key="your-api-key", + model_name="gpt-4o", + temperature=0.1 + ), max_loops=3, autosave=True, dashboard=False, @@ -442,6 +453,7 @@ Run the agent with multiple modalities useful for various real-world tasks in ma import os from dotenv import load_dotenv from swarms import Agent +from swarms.models import OpenAIChat from swarm_models import GPT4VisionAPI @@ -450,7 +462,7 @@ load_dotenv() # Initialize the language model -llm = GPT4VisionAPI( +llm = OpenAIChat( openai_api_key=os.environ.get("OPENAI_API_KEY"), max_tokens=500, ) @@ -552,7 +564,7 @@ Steps: For example, here's an example on how to create an agent from griptape. -Here’s how you can create a custom **Griptape** agent that integrates with the **Swarms** framework by inheriting from the `Agent` class in **Swarms** and overriding the `run(task: str) -> str` method. +Here's how you can create a custom **Griptape** agent that integrates with the **Swarms** framework by inheriting from the `Agent` class in **Swarms** and overriding the `run(task: str) -> str` method. ```python @@ -694,7 +706,7 @@ In this example, each `Agent` represents a task that is executed sequentially. T ```python import os from swarms import Agent, SequentialWorkflow -from swarm_models import OpenAIChat +from swarms.models import OpenAIChat # model = Anthropic(anthropic_api_key=os.getenv("ANTHROPIC_API_KEY")) company = "Nvidia" @@ -911,7 +923,7 @@ The `run` method returns the final output after all agents have processed the in from swarms import Agent, AgentRearrange -from swarm_models import Anthropic +from swarm.models import Anthropic # Initialize the director agent @@ -1288,7 +1300,7 @@ The `run` method returns a dictionary containing the outputs of each agent that ```python import os from swarms import Agent -from swarm_models import OpenAIChat +from swarms.models import OpenAIChat from swarms.structs.spreadsheet_swarm import SpreadSheetSwarm # Define custom system prompts for each social media platform @@ -1613,7 +1625,7 @@ The `SwarmRouter` class is a flexible routing system designed to manage differen import os from dotenv import load_dotenv from swarms import Agent -from swarm_models import OpenAIChat +from swarms.models import OpenAIChat from swarms.structs.swarm_router import SwarmRouter, SwarmType load_dotenv() From 4aa1f4da2614cd41994beb78cd1290469d4e5f2b Mon Sep 17 00:00:00 2001 From: Occupying-Mars Date: Sun, 1 Dec 2024 02:16:52 +0530 Subject: [PATCH 6/6] smore changes --- README.md | 63 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index effb16804..378b8c54b 100644 --- a/README.md +++ b/README.md @@ -141,10 +141,14 @@ model = OpenAIChat( agent = Agent( agent_name="Stock-Analysis-Agent", - model_name="gpt-4o-mini", + system_prompt="You are a stock market analysis expert. Analyze market trends and provide insights.", + llm=model, max_loops="auto", interactive=True, streaming_on=True, + verbose=True, + autosave=True, + saved_state_path="stock_analysis_agent.json" ) agent.run("What is the current market trend for tech stocks?") @@ -157,29 +161,31 @@ The `Agent` class offers a range of settings to tailor its behavior to specific | Setting | Description | Default Value | | --- | --- | --- | | `agent_name` | The name of the agent. | "DefaultAgent" | -| `system_prompt` | The system prompt to use for the agent. | "Default system prompt." | -| `llm` | The language model to use for processing tasks. | `OpenAIChat` instance | +| `system_prompt` | The system prompt to use for the agent. | None | +| `llm` | The language model to use for processing tasks. | Required | | `max_loops` | The maximum number of loops to execute for a task. | 1 | | `autosave` | Enables or disables autosaving of the agent's state. | False | | `dashboard` | Enables or disables the dashboard for the agent. | False | | `verbose` | Controls the verbosity of the agent's output. | False | +| `streaming_on` | Enables or disables response streaming. | True | | `dynamic_temperature_enabled` | Enables or disables dynamic temperature adjustment for the language model. | False | -| `saved_state_path` | The path to save the agent's state. | "agent_state.json" | -| `user_name` | The username associated with the agent. | "default_user" | -| `retry_attempts` | The number of retry attempts for failed tasks. | 1 | -| `context_length` | The maximum length of the context to consider for tasks. | 200000 | -| `return_step_meta` | Controls whether to return step metadata in the output. | False | -| `output_type` | The type of output to return (e.g., "json", "string"). | "string" | +| `saved_state_path` | The path to save the agent's state. | None | +| `user_name` | The username associated with the agent. | "User" | +| `retry_attempts` | The number of retry attempts for failed tasks. | 3 | +| `context_length` | The maximum length of the context to consider for tasks. | 8192 | +| `multi_modal` | Enables or disables multimodal support. | False | +| `code_interpreter` | Enables or disables code execution. | False | +| `self_healing_enabled` | Enables or disables error recovery. | False | +| `sentiment_threshold` | The threshold for response evaluation. | 0.7 | +| `tags` | A list of strings for categorizing the agent. | None | +| `use_cases` | A list of dictionaries documenting the agent's use cases. | None | ```python import os from swarms import Agent from swarms.models import OpenAIChat - -from swarms.prompts.finance_agent_sys_prompt import ( - FINANCIAL_AGENT_SYS_PROMPT, -) +from swarms.prompts.finance_agent_sys_prompt import FINANCIAL_AGENT_SYS_PROMPT from dotenv import load_dotenv load_dotenv() @@ -187,7 +193,7 @@ load_dotenv() # Get the OpenAI API key from the environment variable api_key = os.getenv("OPENAI_API_KEY") -# Create an instance of the OpenAIChat class +# Create model instance model = OpenAIChat( openai_api_key=api_key, model_name="gpt-4o-mini", temperature=0.1 ) @@ -201,21 +207,29 @@ agent = Agent( autosave=True, dashboard=False, verbose=True, + streaming_on=True, dynamic_temperature_enabled=True, saved_state_path="finance_agent.json", user_name="swarms_corp", - retry_attempts=1, + retry_attempts=3, context_length=200000, - return_step_meta=False, - output_type="string", - streaming_on=False, + multi_modal=False, + code_interpreter=True, + self_healing_enabled=True, + sentiment_threshold=0.7, + tags=["finance", "analysis"], + use_cases=[{"name": "Financial Analysis", "description": "Analyze financial data and provide insights"}] ) +# Modern method usage +agent.update_system_prompt("New system prompt") +agent.update_max_loops(5) +agent.update_loop_interval(2) +agent.update_retry_attempts(5) +print(agent.get_llm_parameters()) -agent.run( - "How can I establish a ROTH IRA to buy stocks and get a tax break? What are the criteria" -) - +# Run the agent +agent.run("Analyze the latest quarterly financial report for Tesla") ``` ----- ### Integrating RAG with Swarms for Enhanced Long-Term Memory @@ -244,7 +258,10 @@ from swarms.memory import ChromaDB chromadb = ChromaDB( metric="cosine", # Metric for similarity measurement output_dir="finance_agent_rag", # Directory for storing RAG data - # docs_folder="artifacts", # Uncomment and specify the folder containing your documents + limit_tokens=1000, # Maximum tokens per query + n_results=1, # Number of results to retrieve + docs_folder=None, # Optional folder containing documents to add + verbose=False # Enable verbose logging if needed ) ```