Skip to content

Commit 55b923f

Browse files
committed
fix: resolve indentation error and remove dead code in vision.py
1 parent bf4e059 commit 55b923f

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

backend/app/rag/vision.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff 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

257237
def generate_captions_for_chunks(chunks: List[Dict[str, Any]]) -> None:

0 commit comments

Comments
 (0)