Skip to content

(+) pdf reader - #5

Open
scalandr wants to merge 2 commits into
mainfrom
pdf_reader
Open

(+) pdf reader#5
scalandr wants to merge 2 commits into
mainfrom
pdf_reader

Conversation

@scalandr

Copy link
Copy Markdown
Collaborator

universe_kb_add_pdf is the added action for a one-shot PDF ingestion. The action decomposes one PDF into several retrievable knowledge assets. Text chunks go to the text embedding space, images to the vision space, and tables to a dedicated table space. The multimodal vector store backs these with three Chroma collections (_text, _vision, _table). At the workflow layer, the action validates the target universe, accepts either a server-side pdf_path or base64 pdf_content, and forwards the request to POST /kbs/{kb_name}/add_pdf together with optional extraction controls: extract_images, extract_tables, persist_extracted_images, and extracted_image_dir. add_pdf_document() uses PyMuPDF (fitz) to open the PDF, assigns a generated document_id, enriches metadata with source, document type, and extraction timestamp, and then iterates page by page. Text is extracted with page.get_text("text") and ingested through the generic add_document() path as text chunks. Images are discovered with page.get_images(full=True), extracted as raw bytes, and optionally persisted to disk under a deterministic asset directory derived from the KB configuration or the explicit extracted_image_dir. Before ingestion, the code computes rich spatial metadata for each image, including bounding box coordinates, page region, normalized position, surrounding text, detected figure/table anchors, and nearby section context. Tables are handled similarly through page.find_tables() when available: extracted rows are serialized to CSV-like text, augmented with positional metadata, and stored as table modality items.

universe_kb_search now supports three modes: direct_search, rolling_window, and agentic_internal_questions. direct_search is the standard (already available) knowledge base search. The two added modes add relevance control on top of retrieval. rolling_window fetches a larger candidate set, deduplicates it by id, source, or document, and evaluates candidates batch by batch using the agent itself as a strict yes/no relevance judge. agentic_internal_questions first asks the agent to generate a small set of research subquestions, searches the KB for each one, deduplicates the union of results, and again filters them through agent-based relevance checks.

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