Audit, Compact, and Optimize LanceDB Vector Tables with Stale Version Pruning
Audit LanceDB vector tables for fragment fragmentation and tombstoned rows, track trends in KV, and compact files with operator approval and verification.
Extract structured data from PDFs and web pages with Kestra and OpenAI GPT-4o. Parse documents into JSON fields and store results in PostgreSQL and Slack.
Extract structured data from unstructured documents using OpenAI GPT-4o and a configurable JSON schema. This blueprint downloads a document from any URL (PDF, HTML page, or plain text), parses readable text with format detection, sends it to GPT-4o to pull out the exact fields you define at runtime, and persists the results to PostgreSQL and Slack. It turns invoices, contracts, receipts, reports, and forms into queryable, auditable data without standing up a dedicated document processing service or hand coding a parser per document type.
download_document task (io.kestra.plugin.core.http.Download) fetches the file from the document_url input over HTTP.extract_text task (io.kestra.plugin.scripts.python.Script) inspects the file header and extracts text accordingly: PDFs via PyPDF2, HTML and text via BeautifulSoup4 (stripping script, style, nav, and footer tags). It truncates content to 8000 characters to stay within token limits and reports a character count.extract_structured_data task (io.kestra.plugin.openai.ChatCompletion) sends the text to gpt-4o with a jsonResponseSchema, returning extracted_fields, a confidence score, missing_fields, and extraction_notes. The extraction_schema and document_type inputs steer the prompt so you control which fields come back.save_to_postgres task (io.kestra.plugin.jdbc.postgresql.Queries) creates a document_extractions table if needed and inserts the extracted JSONB, confidence, and source metadata. It runs conditionally via runIf based on the output_destination input.notify_slack task (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts a formatted message with the extracted fields, confidence percentage, characters processed, and any missing fields, also gated by runIf.OpenAI gives you a model API, not a pipeline. Kestra supplies the orchestration around it: declarative YAML you can version and review, event triggers and schedules to process documents as they arrive, retries on transient HTTP or API failures, conditional runIf branching to route output, and full execution lineage so every extraction is traceable from source URL to stored row. The model has no scheduler, no state, and no way to chain download, parse, persist, and notify into one auditable run. Kestra fills that gap.
gpt-4oConfigure these secrets in your Kestra instance:
OPENAI_API_KEY: API key for the OpenAI ChatCompletion taskSLACK_WEBHOOK_URL: incoming webhook URL for Slack notificationsPOSTGRES_URL: JDBC connection URL for the target databasePOSTGRES_USER: PostgreSQL usernamePOSTGRES_PASSWORD: PostgreSQL passworddocument_url pointing to a sample PDF or web page.extraction_schema input to match the fields you need.output_destination (postgres, slack, or both) and execute.Loop for bulk processing.