From ba316eba0754a6b37fbf87a9fa1425c8afc8394c Mon Sep 17 00:00:00 2001 From: Kye Date: Sat, 9 Dec 2023 13:58:25 -0800 Subject: [PATCH] [CLEANUP CHORES] --- .flake8 | 2 - .gitignore | 2 +- pyproject.toml | 2 +- swarms/cli/_cli.py | 106 +++++++++++++++++++++++++++------------- swarms/cli/run_file.py | 15 ++++++ swarms/structs/agent.py | 4 ++ 6 files changed, 92 insertions(+), 39 deletions(-) delete mode 100644 .flake8 create mode 100644 swarms/cli/run_file.py diff --git a/.flake8 b/.flake8 deleted file mode 100644 index eedac54c..00000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -extend-ignore = E501, W292, W291, W293 diff --git a/.gitignore b/.gitignore index aa73b19e..93f8e5c0 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,7 @@ error.txt errors.txt - +Autonomous-Agent-XYZ1B_state.json # Distribution / packaging .Python build/ diff --git a/pyproject.toml b/pyproject.toml index 6485df3e..203f5645 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "2.6.1" +version = "2.6.2" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/cli/_cli.py b/swarms/cli/_cli.py index 5b4a3ebd..c4e67b7b 100644 --- a/swarms/cli/_cli.py +++ b/swarms/cli/_cli.py @@ -1,40 +1,76 @@ -# import argparse -# import sys - -# def run_file(): -# parser = argparse.ArgumentParser(description='Swarms CLI') -# parser.add_argument('file_name', help='Python file containing Swarms code to run') - -# # Help message for the -h flag is automatically generated by argparse -# parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1.0') - -# # Check deployments for a given model -# parser.add_argument('-c', '--check', help='Check deployments for a given agent') - -# args = parser.parse_args() - -# # Execute the specified file -# try: -# with open(args.file_name, 'r') as file: -# exec(file.read(), globals()) -# except FileNotFoundError: -# print(f"Error: File '{args.file_name}' not found.") -# sys.exit(1) -# except Exception as e: -# print(f"Error executing file '{args.file_name}': {e}") -# sys.exit(1) - -# if __name__ == '__main__': -# main() - -# swarms/cli/_cli.py +import argparse import sys -import subprocess + def run_file(): - if len(sys.argv) != 3 or sys.argv[1] != "run": - print("Usage: swarms run file_name.py") + parser = argparse.ArgumentParser(description="Swarms CLI") + parser.add_argument( + "file_name", help="Python file containing Swarms code to run" + ) + # Help message for the -h flag is automatically generated by argparse + parser.add_argument( + "-v", "--version", action="version", version="%(prog)s 0.1.0" + ) + + # Check deployments for a given model + parser.add_argument( + "-c", "--check", help="Check deployments for a given agent" + ) + + # Generate an API key for a given agent + parser.add_argument( + "-g", + "--generate", + help="Generate an API key for a given agent", + ) + + # Signin to swarms with a given API key + parser.add_argument( + "-s", "--signin", help="Signin to swarms with a given API key" + ) + + # Signout of swarms + parser.add_argument("-o", "--signout", help="Signout of swarms") + + # List all agents + parser.add_argument("-l", "--list", help="List all agents") + + # List all deployments + parser.add_argument( + "-d", "--deployments", help="List all deployments" + ) + + # Pricing information + parser.add_argument("-p", "--pricing", help="Pricing information") + + # Run a deployment + parser.add_argument("-r", "--run", help="Run a deployment") + + # Stop a deployment + parser.add_argument("-t", "--stop", help="Stop a deployment") + + # Delete a deployment + parser.add_argument("-x", "--delete", help="Delete a deployment") + + # Get a deployment + parser.add_argument("-e", "--get", help="Get a deployment") + + # Get a deployment's logs + parser.add_argument( + "-z", "--logs", help="Get a deployment's logs" + ) + + # Parse the arguments + args = parser.parse_args() + + # Execute the specified file + try: + with open(args.file_name, "r") as file: + exec(file.read(), globals()) + except FileNotFoundError: + print(f"Error: File '{args.file_name}' not found.") + sys.exit(1) + except Exception as e: + print(f"Error executing file '{args.file_name}': {e}") sys.exit(1) - file_name = sys.argv[2] - subprocess.run(["python", file_name], check=True) diff --git a/swarms/cli/run_file.py b/swarms/cli/run_file.py new file mode 100644 index 00000000..a8cd4439 --- /dev/null +++ b/swarms/cli/run_file.py @@ -0,0 +1,15 @@ +import sys +import subprocess + +def run_file(): + """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) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 9d490877..fbfd4620 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -192,6 +192,8 @@ class Agent: tokenizer: Optional[Any] = None, memory: Optional[VectorDatabase] = None, preset_stopping_token: Optional[bool] = False, + traceback: Any = None, + traceback_handlers: Any = None, *args, **kwargs: Any, ): @@ -232,6 +234,8 @@ class Agent: self.tokenizer = tokenizer self.memory = memory self.preset_stopping_token = preset_stopping_token + self.traceback = traceback + self.traceback_handlers = traceback_handlers # self.system_prompt = AGENT_SYSTEM_PROMPT_3