Skip to content

Commit 62a9399

Browse files
qchappCopilot
andauthored
Update src/ai_agent/agent/tools/gradio_space_tool.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d0d8eb4 commit 62a9399

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/ai_agent/agent/tools/gradio_space_tool.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def _download_to_temp(url: str) -> Optional[str]:
6666
ext = ".jpg"
6767
else:
6868
ext = ".bin"
69-
fd = tempfile.NamedTemporaryFile(delete=False, prefix="demo_result_", suffix=ext)
70-
fd.write(r.content)
71-
fd.flush(); fd.close()
72-
return fd.name
69+
with tempfile.NamedTemporaryFile(delete=False, prefix="demo_result_", suffix=ext) as fd:
70+
fd.write(r.content)
71+
fd.flush()
72+
return fd.name
7373
except Exception:
7474
return None
7575

0 commit comments

Comments
 (0)