mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 05:54:26 +01:00
fix: Update agent creation logic and error message
- 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.
This commit is contained in:
9
cli.py
9
cli.py
@@ -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(
|
||||
@@ -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",
|
||||
)
|
||||
)
|
||||
@@ -886,6 +888,5 @@ def update(agent_name, hash, branch):
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
||||
Reference in New Issue
Block a user