parent
4f39f4fe0a
commit
466f27a714
@ -1,75 +1,53 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import sys
|
from swarms.agents.simple_agent import SimpleAgent, get_llm_by_name
|
||||||
|
|
||||||
|
|
||||||
def cli():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Swarms CLI")
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument(
|
prog="swarms",
|
||||||
"file_name", help="Python file containing Swarms code to run"
|
description=(
|
||||||
)
|
"Run the SimpleAgent with a specified language model."
|
||||||
# Help message for the -h flag is automatically generated by argparse
|
),
|
||||||
parser.add_argument(
|
|
||||||
"-v", "--version", action="version", version="%(prog)s 0.1.0"
|
|
||||||
)
|
)
|
||||||
|
subparsers = parser.add_subparsers(dest="command")
|
||||||
|
|
||||||
# Check deployments for a given model
|
run_parser = subparsers.add_parser(
|
||||||
parser.add_argument(
|
"run", help="Run the SimpleAgent."
|
||||||
"-c", "--check", help="Check deployments for a given agent"
|
|
||||||
)
|
)
|
||||||
|
run_parser.add_argument(
|
||||||
# Generate an API key for a given agent
|
"modelname",
|
||||||
parser.add_argument(
|
type=str,
|
||||||
"-g",
|
help="The name of the language model to use.",
|
||||||
"--generate",
|
|
||||||
help="Generate an API key for a given agent",
|
|
||||||
)
|
)
|
||||||
|
run_parser.add_argument(
|
||||||
# Signin to swarms with a given API key
|
"--iters",
|
||||||
parser.add_argument(
|
type=int,
|
||||||
"-s", "--signin", help="Signin to swarms with a given API key"
|
default="automatic",
|
||||||
|
help=(
|
||||||
|
'Number of iterations or "automatic" for infinite loop.'
|
||||||
|
' Defaults to "automatic".'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Signout of swarms
|
# Add a help command
|
||||||
parser.add_argument("-o", "--signout", help="Signout of swarms")
|
help_parser = subparsers.add_parser(
|
||||||
|
"help", help="Show this help message and exit."
|
||||||
# List all agents
|
|
||||||
parser.add_argument("-l", "--list", help="List all agents")
|
|
||||||
|
|
||||||
# List all deployments
|
|
||||||
parser.add_argument(
|
|
||||||
"-d", "--deployments", help="List all deployments"
|
|
||||||
)
|
)
|
||||||
|
help_parser.set_defaults(func=lambda args: parser.print_help())
|
||||||
|
|
||||||
# Pricing information
|
args = parser.parse_args()
|
||||||
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
|
if hasattr(args, "func"):
|
||||||
parser.add_argument(
|
args.func(args)
|
||||||
"-z", "--logs", help="Get a deployment's logs"
|
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)
|
||||||
|
|
||||||
# Parse the arguments
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Execute the specified file
|
# if __name__ == "__main__":
|
||||||
try:
|
# main()
|
||||||
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)
|
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
from swarms.tokenizers.r_tokenizers import (
|
||||||
|
SentencePieceTokenizer,
|
||||||
|
HuggingFaceTokenizer,
|
||||||
|
Tokenizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"SentencePieceTokenizer",
|
||||||
|
"HuggingFaceTokenizer",
|
||||||
|
"Tokenizer",
|
||||||
|
]
|
Loading…
Reference in new issue