Skip to content

Commit

Permalink
loop over formats
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed Oct 16, 2024
1 parent 5fa377e commit c8eea97
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions vision_agent/tools/meta_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,21 +833,21 @@ def extract_and_save_files_to_artifacts(
# file system.
files = {}
for res in result.results:
if len(res.formats()) == 1 and res.formats()[0] in ["png", "jpeg", "mp4"]: # type: ignore
format = res.formats()[0] # type: ignore
if format == "png":
data = base64.b64decode(res.png) if res.png is not None else None
elif format == "jpeg":
data = base64.b64decode(res.jpeg) if res.jpeg is not None else None
elif format == "mp4":
data = base64.b64decode(res.mp4) if res.mp4 is not None else None
else:
data = None

if format not in files:
files[format] = [data]
else:
files[format].append(data)
for format in res.formats():
if format in ["png", "jpeg", "mp4"]: # type: ignore
if format == "png":
data = base64.b64decode(res.png) if res.png is not None else None
elif format == "jpeg":
data = base64.b64decode(res.jpeg) if res.jpeg is not None else None
elif format == "mp4":
data = base64.b64decode(res.mp4) if res.mp4 is not None else None
else:
data = None

if format not in files:
files[format] = [data]
else:
files[format].append(data)

response = _extract_file_names(
code,
Expand Down

0 comments on commit c8eea97

Please sign in to comment.