pull/440/head
Kye 9 months ago
parent fc587b3183
commit d8b42f08e7

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "4.7.0" version = "4.7.1"
description = "Swarms - Pytorch" description = "Swarms - Pytorch"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]
@ -68,7 +68,3 @@ unfixable = []
line-length = 70 line-length = 70
target-version = ['py38'] target-version = ['py38']
preview = true preview = true
[tool.poetry.scripts]
swarms = 'swarms.cli._cli:main'

@ -2,10 +2,10 @@ import logging
from collections import defaultdict from collections import defaultdict
from typing import Callable, Sequence from typing import Callable, Sequence
from swarms import Agent, Anthropic from swarms import Agent, Anthropic
from swarms.structs.base_swarm import BaseSwarm
# Assuming the existence of an appropriate Agent class and logger setup # Assuming the existence of an appropriate Agent class and logger setup
class AgentRearrange: class AgentRearrange(BaseSwarm):
def __init__( def __init__(
self, self,
agents: Sequence[Agent] = None, agents: Sequence[Agent] = None,
@ -13,6 +13,7 @@ class AgentRearrange:
custom_prompt: str = None, custom_prompt: str = None,
callbacks: Sequence[Callable] = None, callbacks: Sequence[Callable] = None,
): ):
super().__init__()
if not all(isinstance(agent, Agent) for agent in agents): if not all(isinstance(agent, Agent) for agent in agents):
raise ValueError( raise ValueError(
"All elements must be instances of the Agent class." "All elements must be instances of the Agent class."

@ -1,54 +0,0 @@
import argparse
from swarms.agents.simple_agent import SimpleAgent, get_llm_by_name
def main():
parser = argparse.ArgumentParser(
prog="swarms",
description=(
"Run the SimpleAgent with a specified language model."
),
)
subparsers = parser.add_subparsers(dest="command")
run_parser = subparsers.add_parser(
"run", help="Run the SimpleAgent."
)
run_parser.add_argument(
"modelname",
type=str,
help="The name of the language model to use.",
)
run_parser.add_argument(
"--iters",
type=int,
default="automatic",
help=(
'Number of iterations or "automatic" for infinite loop.'
' Defaults to "automatic".'
),
)
# Add a help command
help_parser = subparsers.add_parser(
"help", help="Show this help message and exit."
)
help_parser.set_defaults(func=lambda args: parser.print_help())
args = parser.parse_args()
if hasattr(args, "func"):
args.func(args)
elif args.command == "run":
llm = get_llm_by_name(args.modelname)
if llm is None:
raise ValueError(
"No language model found with name"
f" '{args.modelname}'"
)
SimpleAgent(llm, iters=args.iters)
# if __name__ == "__main__":
# main()

@ -1,16 +0,0 @@
import subprocess
import sys
def run_file(filename: str):
"""Run a given file.
Usage: swarms run file_name.py
"""
if len(sys.argv) != 3 or sys.argv[1] != "run":
print("Usage: swarms run file_name.py")
sys.exit(1)
file_name = sys.argv[2]
subprocess.run(["python", file_name], check=True)
Loading…
Cancel
Save