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:
parent
dd8e660f0a
commit
0b456a18a3
1 changed files with 6 additions and 9 deletions
|
|
@ -78,15 +78,12 @@ def vision_llm_chunk(binary, vision_model, prompt=None, callback=None):
|
||||||
txt = ""
|
txt = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
img_binary = io.BytesIO()
|
with io.BytesIO() as img_binary:
|
||||||
img.save(img_binary, format='JPEG')
|
img.save(img_binary, format='JPEG')
|
||||||
img_binary.seek(0)
|
img_binary.seek(0)
|
||||||
|
ans = clean_markdown_block(vision_model.describe_with_prompt(img_binary.read(), prompt))
|
||||||
ans = clean_markdown_block(vision_model.describe_with_prompt(img_binary.read(), prompt))
|
txt += "\n" + ans
|
||||||
|
return txt
|
||||||
txt += "\n" + ans
|
|
||||||
|
|
||||||
return txt
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
callback(-1, str(e))
|
callback(-1, str(e))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue