(+) pdf reader - #5
Open
scalandr wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
universe_kb_add_pdfis 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-sidepdf_pathor base64pdf_content, and forwards the request toPOST /kbs/{kb_name}/add_pdftogether with optional extraction controls:extract_images,extract_tables,persist_extracted_images, andextracted_image_dir.add_pdf_document()uses PyMuPDF (fitz) to open the PDF, assigns a generateddocument_id, enriches metadata with source, document type, and extraction timestamp, and then iterates page by page. Text is extracted withpage.get_text("text")and ingested through the genericadd_document()path as text chunks. Images are discovered withpage.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 explicitextracted_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 throughpage.find_tables()when available: extracted rows are serialized to CSV-like text, augmented with positional metadata, and stored astablemodality items.universe_kb_searchnow supports three modes:direct_search,rolling_window, andagentic_internal_questions.direct_searchis the standard (already available) knowledge base search. The two added modes add relevance control on top of retrieval.rolling_windowfetches 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_questionsfirst 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.