Skip to content

Commit

Permalink
fix: Update agent creation logic and error message
Browse files Browse the repository at this point in the history
- Update the logic for checking if an agent name already exists to be case-insensitive.
- Update the error message when an agent with the same name already exists to specify that the name should be unique regardless of case.
  • Loading branch information
Swiftyos committed Oct 30, 2023
1 parent 2bd0582 commit d9fbd26
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ def create(agent_name):
return
try:
new_agent_dir = f"./autogpts/{agent_name}"
agent_json_file = f"./arena/{agent_name}.json"
new_agent_name = f"{agent_name.lower()}.json"

if not os.path.exists(new_agent_dir) and not os.path.exists(agent_json_file):
existing_arena_files = [name.lower() for name in os.listdir("./arena/")]

if not os.path.exists(new_agent_dir) and not new_agent_name in existing_arena_files:
shutil.copytree("./autogpts/forge", new_agent_dir)
click.echo(
click.style(
Expand All @@ -248,7 +250,7 @@ def create(agent_name):
else:
click.echo(
click.style(
f"😞 Agent '{agent_name}' already exists. Enter a different name for your agent",
f"😞 Agent '{agent_name}' already exists. Enter a different name for your agent, the name needs to be unique regardless of case",
fg="red",
)
)
Expand Down Expand Up @@ -886,6 +888,5 @@ def update(agent_name, hash, branch):
)
)


if __name__ == "__main__":
cli()

0 comments on commit d9fbd26

Please sign in to comment.