File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ def _openai_caption(image_bytes: bytes) -> str:
182182 )
183183 return response .choices [0 ].message .content .strip ()
184184
185- except Exception as exc :
185+ except Exception as exc :
186186 logger .warning (
187187 "OpenAI vision caption failed — falling back to OCR/placeholder. "
188188 "This may be a transient API error (rate-limit, timeout). Error: %s" ,
@@ -232,26 +232,6 @@ def caption_image(
232232 dims = "unknown size"
233233
234234 return f"Figure on page { page } ({ dims } )." if page else f"Figure ({ dims } )."
235- # Placeholder for provider-based captioning (e.g., OpenAI / LLaVA hooks)
236- provider = getattr (settings , "VISION_PROVIDER" , None )
237-
238- if provider == "openai" :
239- caption = _openai_caption (image_bytes )
240- if caption :
241- return caption
242-
243- ocr = _ocr_caption (image_bytes )
244- if ocr :
245- return ocr
246-
247- # Derive dimensions for the placeholder
248- try :
249- pix = fitz .Pixmap (image_bytes )
250- dims = f"{ pix .width } x{ pix .height } px"
251- except Exception :
252- dims = "unknown size"
253-
254- return f"Figure on page { page } ({ dims } )." if page else f"Figure ({ dims } )."
255235
256236
257237def generate_captions_for_chunks (chunks : List [Dict [str , Any ]]) -> None :
You can’t perform that action at this time.
0 commit comments