Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(agent/setup): Fix revising constraints and best practices (#6777)

Thunder Drag49a6d6820025
diff --git a/autogpts/autogpt/autogpt/app/setup.py b/autogpts/autogpt/autogpt/app/setup.py
index 8a271d26f4..df4e9436cd 100644
--- a/autogpts/autogpt/autogpt/app/setup.py
+++ b/autogpts/autogpt/autogpt/app/setup.py
@@ -89,7 +89,9 @@ async def interactively_revise_ai_settings(
)
# Revise constraints
- for i, constraint in enumerate(directives.constraints):
+ i = 0
+ while i < len(directives.constraints):
+ constraint = directives.constraints[i]
print_attribute(f"Constraint {i+1}:", f'"{constraint}"')
new_constraint = (
await clean_input(
@@ -99,11 +101,15 @@ async def interactively_revise_ai_settings(
)
or constraint
)
+
if new_constraint == "-":
directives.constraints.remove(constraint)
+ continue
elif new_constraint:
directives.constraints[i] = new_constraint
+ i += 1
+
# Add new constraints
while True:
new_constraint = await clean_input(
@@ -115,7 +121,9 @@ async def interactively_revise_ai_settings(
directives.constraints.append(new_constraint)
# Revise resources
- for i, resource in enumerate(directives.resources):
+ i = 0
+ while i < len(directives.resources):
+ resource = directives.resources[i]
print_attribute(f"Resource {i+1}:", f'"{resource}"')
new_resource = (
await clean_input(
@@ -127,9 +135,12 @@ async def interactively_revise_ai_settings(
)
if new_resource == "-":
directives.resources.remove(resource)
+ continue
elif new_resource:
directives.resources[i] = new_resource
+ i += 1
+
# Add new resources
while True:
new_resource = await clean_input(
@@ -141,7 +152,9 @@ async def interactively_revise_ai_settings(
directives.resources.append(new_resource)
# Revise best practices
- for i, best_practice in enumerate(directives.best_practices):
+ i = 0
+ while i < len(directives.best_practices):
+ best_practice = directives.best_practices[i]
print_attribute(f"Best Practice {i+1}:", f'"{best_practice}"')
new_best_practice = (
await clean_input(
@@ -153,9 +166,12 @@ async def interactively_revise_ai_settings(
)
if new_best_practice == "-":
directives.best_practices.remove(best_practice)
+ continue
elif new_best_practice:
directives.best_practices[i] = new_best_practice
+ i += 1
+
# Add new best practices
while True:
new_best_practice = await clean_input(