Refactor: Improve the buffer close for vision_llm_chunk (#9845)

### What problem does this PR solve?

Improve the buffer close for vision_llm_chunk

### Type of change

- [x] Refactoring
This commit is contained in:
Stephen Hu
2025-09-02 10:31:37 +08:00
committed by GitHub
parent dd8e660f0a
commit 0b456a18a3

View File

@ -78,14 +78,11 @@ def vision_llm_chunk(binary, vision_model, prompt=None, callback=None):
txt = ""
try:
img_binary = io.BytesIO()
with io.BytesIO() as img_binary:
img.save(img_binary, format='JPEG')
img_binary.seek(0)
ans = clean_markdown_block(vision_model.describe_with_prompt(img_binary.read(), prompt))
txt += "\n" + ans
return txt
except Exception as e: