Skip to content

Commit

Permalink
fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed Oct 11, 2024
1 parent 8a84f4d commit 7b2e87f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions vision_agent/agent/vision_agent_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
_MAX_TABULATE_COL_WIDTH,
DefaultImports,
extract_code,
extract_json,
extract_tag,
format_memory,
print_code,
Expand Down Expand Up @@ -85,7 +84,7 @@ def strip_function_calls(code: str, exclusions: Optional[List[str]] = None) -> s
for node in nodes_to_remove:
node.parent.remove(node)
cleaned_code = red.dumps().strip()
return cleaned_code
return cleaned_code if isinstance(cleaned_code, str) else code


def write_code(
Expand Down Expand Up @@ -286,8 +285,8 @@ def debug_code(
stream=False,
)
fixed_code_and_test_str = cast(str, fixed_code_and_test_str)
thoughts = extract_tag(fixed_code_and_test_str, "thoughts")
thoughts = thoughts if thoughts is not None else ""
thoughts_tag = extract_tag(fixed_code_and_test_str, "thoughts")
thoughts = thoughts_tag if thoughts_tag is not None else ""
fixed_code = extract_tag(fixed_code_and_test_str, "code")
fixed_test = extract_tag(fixed_code_and_test_str, "test")

Expand All @@ -312,7 +311,7 @@ def debug_code(
new_working_memory.append(
{
"code": f"{code}\n{test}",
"feedback": cast(str, thoughts),
"feedback": thoughts,
"edits": get_diff(f"{old_code}\n{old_test}", f"{code}\n{test}"),
}
)
Expand Down
2 changes: 1 addition & 1 deletion vision_agent/agent/vision_agent_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def write_plans(

count = 0
while not _check_plan_format(plans) and count < 3:
_LOGGER.info(f"Invalid plan format. Retrying.")
_LOGGER.info("Invalid plan format. Retrying.")
plans = extract_json(model(chat, stream=False)) # type: ignore
count += 1
if count == 3:
Expand Down
3 changes: 2 additions & 1 deletion vision_agent/tools/meta_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ def use_extra_vision_agent_args(

if custom_tool_names is not None:
node.value[1].value.append(f"custom_tool_names={custom_tool_names}")
return red.dumps().strip()
cleaned_code = red.dumps().strip()
return cleaned_code if isinstance(cleaned_code, str) else code


def use_object_detection_fine_tuning(
Expand Down

0 comments on commit 7b2e87f

Please sign in to comment.