mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
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:
@ -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))
|
||||||
|
|||||||
Reference in New Issue
Block a user