diff --git a/.github/workflows/cron_job_tests.yml b/.github/workflows/cron_job_tests.yml new file mode 100644 index 00000000..60bd98d3 --- /dev/null +++ b/.github/workflows/cron_job_tests.yml @@ -0,0 +1,27 @@ +name: Run pytest + +on: + schedule: + # This will run the job every day at a random minute past the hour + - cron: '0 0 * * *' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + pip install swarms + + - name: Run tests + run: pytest \ No newline at end of file diff --git a/.gitignore b/.gitignore index e79d91b1..7e6550d6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ static/generated runs chroma Unit Testing Agent_state.json +Devin_state.json swarms/__pycache__ artifacts venv diff --git a/devin.py b/devin.py new file mode 100644 index 00000000..d97bb399 --- /dev/null +++ b/devin.py @@ -0,0 +1,77 @@ +""" +Plan -> act in a loop until observation is met + + +# Tools +- Terminal +- Text Editor +- Browser +""" +from swarms import Agent, OpenAIChat, tool +import subprocess + +# Model +llm = OpenAIChat() + + +# Tools +@tool +def terminal( + code: str, +): + """ + Run code in the terminal. + + Args: + code (str): The code to run in the terminal. + + Returns: + str: The output of the code. + """ + out = subprocess.run( + code, shell=True, capture_output=True, text=True + ).stdout + return str(out) + + +@tool +def browser(query: str): + """ + Search the query in the browser. + + Args: + query (str): The query to search in the browser. + + Returns: + str: The search results. + """ + import webbrowser + + url = f"https://www.google.com/search?q={query}" + webbrowser.open(url) + return f"Searching for {query} in the browser." + + +# Agent +agent = Agent( + agent_name="Devin", + system_prompt=( + "Autonomous agent that can interact with humans and other" + " agents. Be Helpful and Kind. Use the tools provided to" + " assist the user." + ), + llm=llm, + max_loops=4, + autosave=True, + dashboard=False, + streaming_on=True, + verbose=True, + stopping_token="", + interactive=True, + tools=[terminal, browser], + # streaming=True, +) + +# Run the agent +out = agent("What is the weather today in palo alto?") +print(out) diff --git a/playground/agents/devin.py b/playground/agents/devin.py deleted file mode 100644 index accb4f65..00000000 --- a/playground/agents/devin.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -Plan -> act in a loop until observation is met - - -# Tools -- Terminal -- Text Editor -- Browser -""" diff --git a/pyproject.toml b/pyproject.toml index 50cf3eed..1c630678 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "4.7.1" +version = "4.7.3" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/__init__.py b/swarms/__init__.py index b3f568e2..23b8d3d5 100644 --- a/swarms/__init__.py +++ b/swarms/__init__.py @@ -1,10 +1,6 @@ -import os - from swarms.telemetry.bootup import bootup # noqa: E402, F403 from swarms.telemetry.sentry_active import activate_sentry -os.environ["WANDB_SILENT"] = "true" - bootup() activate_sentry() diff --git a/swarms/models/__init__.py b/swarms/models/__init__.py index c68e7fb7..b053db3f 100644 --- a/swarms/models/__init__.py +++ b/swarms/models/__init__.py @@ -34,7 +34,6 @@ from swarms.models.popular_llms import ( ) from swarms.models.qwen import QwenVLMultiModal # noqa: E402 -from swarms.models.sam_supervision import SegmentAnythingMarkGenerator from swarms.models.sampling_params import SamplingParams, SamplingType from swarms.models.together import TogetherLLM # noqa: E402 from swarms.models.types import ( # noqa: E402 @@ -74,7 +73,6 @@ __all__ = [ "Replicate", "SamplingParams", "SamplingType", - "SegmentAnythingMarkGenerator", "TextModality", "TogetherLLM", "Vilt", diff --git a/swarms/structs/__init__.py b/swarms/structs/__init__.py index da47be28..852fac0f 100644 --- a/swarms/structs/__init__.py +++ b/swarms/structs/__init__.py @@ -78,6 +78,7 @@ from swarms.structs.utils import ( find_token_in_text, parse_tasks, ) +from swarms.structs.agent_rearrange import AgentRearrange __all__ = [ @@ -147,4 +148,5 @@ __all__ = [ "find_agent_by_id", "find_token_in_text", "parse_tasks", + "AgentRearrange", ] diff --git a/rearrange_agent_example.py b/swarms/structs/agent_rearrange.py similarity index 75% rename from rearrange_agent_example.py rename to swarms/structs/agent_rearrange.py index 8f8d2ce3..4c56d0df 100644 --- a/rearrange_agent_example.py +++ b/swarms/structs/agent_rearrange.py @@ -1,9 +1,10 @@ import logging from collections import defaultdict from typing import Callable, Sequence -from swarms import Agent, Anthropic +from swarms.structs.agent import Agent from swarms.structs.base_swarm import BaseSwarm + # Assuming the existence of an appropriate Agent class and logger setup class AgentRearrange(BaseSwarm): def __init__( @@ -12,6 +13,8 @@ class AgentRearrange(BaseSwarm): verbose: bool = False, custom_prompt: str = None, callbacks: Sequence[Callable] = None, + *args, + **kwargs, ): super().__init__() if not all(isinstance(agent, Agent) for agent in agents): @@ -159,76 +162,76 @@ class AgentRearrange(BaseSwarm): return results -## Initialize the workflow -agent = Agent( - agent_name="t", - agent_description=( - "Generate a transcript for a youtube video on what swarms" - " are!" - ), - system_prompt=( - "Generate a transcript for a youtube video on what swarms" - " are!" - ), - llm=Anthropic(), - max_loops=1, - autosave=True, - dashboard=False, - streaming_on=True, - verbose=True, - stopping_token="", -) - -agent2 = Agent( - agent_name="t1", - agent_description=( - "Generate a transcript for a youtube video on what swarms" - " are!" - ), - llm=Anthropic(), - max_loops=1, - system_prompt="Summarize the transcript", - autosave=True, - dashboard=False, - streaming_on=True, - verbose=True, - stopping_token="", -) - -agent3 = Agent( - agent_name="t2", - agent_description=( - "Generate a transcript for a youtube video on what swarms" - " are!" - ), - llm=Anthropic(), - max_loops=1, - system_prompt="Finalize the transcript", - autosave=True, - dashboard=False, - streaming_on=True, - verbose=True, - stopping_token="", -) - - -# Rearrange the agents -rearrange = AgentRearrange( - agents=[agent, agent2, agent3], - verbose=True, - # custom_prompt="Summarize the transcript", -) - -# Run the workflow on a task -results = rearrange( - # pattern="t -> t1, t2 -> t2", - pattern="t -> t1 -> t2", - default_task=( - "Generate a transcript for a YouTube video on what swarms" - " are!" - ), - t="Generate a transcript for a YouTube video on what swarms are!", - # t2="Summarize the transcript", - # t3="Finalize the transcript", -) -# print(results) +# ## Initialize the workflow +# agent = Agent( +# agent_name="t", +# agent_description=( +# "Generate a transcript for a youtube video on what swarms" +# " are!" +# ), +# system_prompt=( +# "Generate a transcript for a youtube video on what swarms" +# " are!" +# ), +# llm=Anthropic(), +# max_loops=1, +# autosave=True, +# dashboard=False, +# streaming_on=True, +# verbose=True, +# stopping_token="", +# ) + +# agent2 = Agent( +# agent_name="t1", +# agent_description=( +# "Generate a transcript for a youtube video on what swarms" +# " are!" +# ), +# llm=Anthropic(), +# max_loops=1, +# system_prompt="Summarize the transcript", +# autosave=True, +# dashboard=False, +# streaming_on=True, +# verbose=True, +# stopping_token="", +# ) + +# agent3 = Agent( +# agent_name="t2", +# agent_description=( +# "Generate a transcript for a youtube video on what swarms" +# " are!" +# ), +# llm=Anthropic(), +# max_loops=1, +# system_prompt="Finalize the transcript", +# autosave=True, +# dashboard=False, +# streaming_on=True, +# verbose=True, +# stopping_token="", +# ) + + +# # Rearrange the agents +# rearrange = AgentRearrange( +# agents=[agent, agent2, agent3], +# verbose=True, +# # custom_prompt="Summarize the transcript", +# ) + +# # Run the workflow on a task +# results = rearrange( +# # pattern="t -> t1, t2 -> t2", +# pattern="t -> t1 -> t2", +# default_task=( +# "Generate a transcript for a YouTube video on what swarms" +# " are!" +# ), +# t="Generate a transcript for a YouTube video on what swarms are!", +# # t2="Summarize the transcript", +# # t3="Finalize the transcript", +# ) +# # print(results) diff --git a/swarms/telemetry/bootup.py b/swarms/telemetry/bootup.py index cf653063..7f4bdfea 100644 --- a/swarms/telemetry/bootup.py +++ b/swarms/telemetry/bootup.py @@ -1,3 +1,4 @@ +import os import logging import warnings @@ -9,5 +10,6 @@ def bootup(): """Bootup swarms""" disable_logging() logging.disable(logging.CRITICAL) + os.environ["WANDB_SILENT"] = "true" warnings.filterwarnings("ignore", category=DeprecationWarning) auto_update()