Skip to content

Studio: extract text from PDF web results#7154

Open
oobabooga wants to merge 1 commit into
unslothai:mainfrom
oobabooga:studio/web-fetch-pdf-extract
Open

Studio: extract text from PDF web results#7154
oobabooga wants to merge 1 commit into
unslothai:mainfrom
oobabooga:studio/web-fetch-pdf-extract

Conversation

@oobabooga

Copy link
Copy Markdown
Member

web_search currently treats PDF URLs as non-text content, so Studio cannot read papers, manuals, or other search results served as PDFs even though the RAG pipeline already supports PDF text extraction.

Fix

Direct PDF fetches now reuse the RAG PyMuPDF/PyMuPDF4LLM parser and return page-delimited text to the model. This works for correctly labeled PDFs and PDFs served as text/plain, text/html, application/octet-stream, or without a Content-Type.

PDF downloads are capped at 10 MiB and read through EOF so the parser receives the cross-reference data. Extraction is limited to 50 pages and 16,000 characters. Oversized, malformed, encrypted, and textless PDFs return short placeholders instead of raw bytes or tracebacks. Other binary formats remain rejected.

Verification

Added regression coverage for declared and mislabeled PDFs, multi-page extraction, the RAG byte-stream path, download and processing limits, preserved page formatting, deadlines, encrypted and malformed files, and PDFs without a text layer.

Focused and related suites: 158 passed, 1 optional dependency test skipped. Repository formatting, Ruff, and whitespace checks also pass.

@oobabooga oobabooga requested a review from danielhanchen as a code owner July 15, 2026 18:37

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for fetching and extracting text from PDF files during web searches, handling mislabeled PDFs via magic byte sniffing, and enforcing download and page limits. The review feedback suggests defensively converting the pages range object to a list before passing it to pymupdf4llm.to_markdown to prevent potential compatibility issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread studio/backend/core/rag/parsers.py
@oobabooga oobabooga force-pushed the studio/web-fetch-pdf-extract branch from 668691e to e68dbc6 Compare July 15, 2026 18:47
@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: e68dbc67c3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant