Skip to content

Commit

Permalink
retry failed json decode (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird authored Jun 20, 2024
1 parent e353567 commit 2dd6813
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,28 @@ def debug_code(
"status": "started",
}
)
fixed_code_and_test = extract_json(
debugger(
FIX_BUG.format(
code=code,
tests=test,
result="\n".join(result.text().splitlines()[-50:]),
feedback=format_memory(working_memory + new_working_memory),

fixed_code_and_test = {"code": "", "test": "", "reflections": ""}
success = False
count = 0
while not success and count < 3:
try:
fixed_code_and_test = extract_json(
debugger(
FIX_BUG.format(
code=code,
tests=test,
result="\n".join(result.text().splitlines()[-50:]),
feedback=format_memory(working_memory + new_working_memory),
)
)
)
)
)
success = True
except Exception as e:
_LOGGER.exception(f"Error while extracting JSON: {e}")

count += 1

old_code = code
old_test = test

Expand Down

0 comments on commit 2dd6813

Please sign in to comment.