### Install and Run SDK Source: https://docs.landing.ai/ade/ade-quickstart Commands to install the necessary libraries and execute the quickstart scripts for both Python and TypeScript environments. ```bash # Python python quickstart.py # TypeScript npm install landingai-ade npx tsx quickstart.ts ``` -------------------------------- ### Install LandingAI ADE Library Source: https://docs.landing.ai/ade/ade-python Command to install the official LandingAI ADE Python package via pip. ```bash pip install landingai-ade ``` -------------------------------- ### Install Landing AI ADE TypeScript Library Source: https://docs.landing.ai/ade/ade-typescript Installs the landingai-ade npm package. This is the first step to using the ADE TypeScript library for document processing. ```bash npm install landingai-ade ``` -------------------------------- ### Grounding Object Example (JSON) Source: https://docs.landing.ai/ade/ade-json-response An example of a single key-value pair within the 'grounding' object, specifically for a logo chunk. It includes bounding box coordinates, page number, and type. ```json { "grounding": { "49c7b7d0-2d8e-4485-8306-3dd820eb13ed": { "box": { "left": 0.06869561225175858, "top": 0.02685479447245598, "right": 0.1445186734199524, "bottom": 0.08676017820835114 }, "page": 0, "type": "chunkLogo" } } } ``` -------------------------------- ### Simple Schema Extraction Example Source: https://docs.landing.ai/ade/ade-extract-response An example of the 'extraction' field's output for a simple schema. It shows the key-value pairs of extracted employee data. ```json { "employee_name": "MICHAEL D BRYAN", "employee_ssn": "555-50-1234", "gross_pay": 6000.00 } ``` -------------------------------- ### Initialize LandingAIADE Client with Environment Variable (Python) Source: https://docs.landing.ai/ade/agentic-api-key Initializes the LandingAIADE client in Python. The library automatically detects the VISION_AGENT_API_KEY environment variable. This example shows explicit passing for clarity. ```python import os from landingai_ade import LandingAIADE client = LandingAIADE( apikey=os.environ.get("VISION_AGENT_API_KEY"), ) ``` -------------------------------- ### Install python-dotenv Package Source: https://docs.landing.ai/ade/agentic-api-key Installs the python-dotenv package, which is used to load environment variables from a .env file into the Python environment. ```bash pip install python-dotenv ``` -------------------------------- ### API Error Handling Guide Source: https://docs.landing.ai/ade/ade-extract-troubleshoot Reference guide for troubleshooting common API errors including schema validation, input conflicts, and document processing failures. ```APIDOC ## Error Handling Reference ### Description This section covers common error scenarios encountered when interacting with the ADE API, specifically focusing on schema validation and request parameter conflicts. ### Status 400: Bad Request Indicates invalid request parameters or malformed JSON schema. - **Invalid JSON schema**: Ensure the schema is valid JSON and follows the required structure. - **Missing 'items' definition**: Arrays must define an `items` property. - **Invalid schema structure**: Sub-schemas within `anyOf` must include a `type` or `anyOf` keyword. - **Failed to download document**: Ensure the `markdown_url` is accessible and points to a valid .md file. - **Invalid extract version**: Use supported versions or 'extract-latest'. ### Status 422: Unprocessable Entity Indicates input validation failures. - **Conflicting Inputs**: Cannot provide both `markdown` and `markdown_url` in the same request. Choose one. ### Schema Validation Example #### Correct Array Definition ```json { "type": "object", "properties": { "sections": { "type": "array", "items": { "type": "object", "properties": { "heading": { "type": "string" }, "content": { "type": "string" } }, "required": ["heading", "content"] } } }, "required": ["sections"] } ``` ### Response Example (Error) { "error": "Cannot provide both 'markdown' and 'markdown_url'. Please provide only one." } ``` -------------------------------- ### Simple Schema Extraction Metadata Example (Text Chunks) Source: https://docs.landing.ai/ade/ade-extract-response Example of 'extraction_metadata' for a simple schema when data is extracted from text chunks. It includes the extracted value and a list of chunk IDs (UUIDs) as references. ```json { "employee_name": { "value": "MICHAEL D BRYAN", "references": [ "72ba3cca-01e5-407b-9fc4-81f54f9f0c51" ] }, "employee_ssn": { "value": "555-50-1234", "references": [ "a3f5d8c9-2b4e-4a1c-8f7e-9d6c5b4a3e2f" ] } } ``` -------------------------------- ### Set Model in Python Client Library Source: https://docs.landing.ai/ade/ade-extract-models This Python code example shows how to set the extraction model when using the `landingai_ade` client library. It defines a schema, initializes the client, and calls the `extract` method with the specified model. ```python import json from pathlib import Path from landingai_ade import LandingAIADE # Define your extraction schema schema_dict = { "type": "object", "properties": { "field1": {"type": "string"}, "field2": {"type": "string"} }, "required": ["field1", "field2"] } client = LandingAIADE() schema_json = json.dumps(schema_dict) response = client.extract( schema=schema_json, markdown=Path("/path/to/output.md"), model="extract-latest" ) ``` -------------------------------- ### Parse Local Documents Source: https://docs.landing.ai/ade/ade-python Example of parsing a local file using the parse method, including saving the output as markdown. ```python from pathlib import Path from landingai_ade import LandingAIADE client = LandingAIADE() # Replace with your file path response = client.parse( document=Path("/path/to/file/document"), model="dpt-2-latest", save_to="output_folder" ) print(response.chunks) # Save Markdown output with open("output.md", "w", encoding="utf-8") as f: f.write(response.markdown) ``` -------------------------------- ### JSON Example of Low Confidence Spans Source: https://docs.landing.ai/ade/ade-json-response This JSON snippet illustrates the structure of the 'low_confidence_spans' array within a grounding object. It shows example entries with 'text', 'span' (start and end character positions), and 'confidence' score. ```json { "grounding": { "6be7d3cf-6664-42c7-906c-4957882e40ff": { "box": { "left": 0.24479518830776215, "top": 0.9269143342971802, "right": 0.6804859042167664, "bottom": 0.9461647272109985 }, "page": 0, "type": "chunkText", "confidence": 0.25, "low_confidence_spans": [ { "text": " 1220", "span": [ 8, 13 ], "confidence": 0.25 }, { "text": "15?", "span": [ 26, 30 ], "confidence": 0.62 } ] } } } ``` -------------------------------- ### Initialize LandingAIADE Client in Notebooks (Python) Source: https://docs.landing.ai/ade/agentic-api-key Initializes the LandingAIADE client in a notebook after setting the API key using the %env magic command. The client automatically picks up the environment variable set in the previous cell. ```python from landingai_ade import LandingAIADE # Initialize the client (it will automatically use VISION_AGENT_API_KEY from environment) client = LandingAIADE() ``` -------------------------------- ### Initialize LandingAIADE Client with .env File (Python) Source: https://docs.landing.ai/ade/agentic-api-key Initializes the LandingAIADE client by loading API keys from a .env file. The load_dotenv() function reads variables from the .env file, and the client is then initialized, automatically using the loaded environment variable. ```python from dotenv import load_dotenv import os from landingai_ade import LandingAIADE # Load environment variables from .env file load_dotenv() # Initialize the client (it will automatically use VISION_AGENT_API_KEY from environment) client = LandingAIADE() ``` -------------------------------- ### Initialize Client for EU Endpoints Source: https://docs.landing.ai/ade/ade-python Demonstrates how to initialize the LandingAIADE client specifically for the EU environment. ```python from pathlib import Path from landingai_ade import LandingAIADE client = LandingAIADE( environment="eu", ) ``` -------------------------------- ### Parse documents with specific models using Python Source: https://docs.landing.ai/ade/ade-parse-models Demonstrates how to initialize the LandingAIADE client and parse a document by explicitly defining the model parameter. If the model parameter is omitted, the library defaults to the latest dpt-2 snapshot. ```python from pathlib import Path from landingai_ade import LandingAIADE client = LandingAIADE() response = client.parse( document=Path("/path/to/document.pdf"), model="dpt-2-latest" ) ``` -------------------------------- ### Nested Schema Extraction Metadata Example Source: https://docs.landing.ai/ade/ade-extract-response Example of 'extraction_metadata' for a nested schema. It maintains the nested structure, showing values and references (chunk IDs) for each field. ```json { "patient_details": { "patient_name": { "value": "John Smith", "references": [ "72ba3cca-01e5-407b-9fc4-81f54f9f0c51" ] }, "date": { "value": "2024-01-15", "references": [ "72ba3cca-01e5-407b-9fc4-81f54f9f0c51" ] } }, "emergency_contact_information": { "emergency_contact_name": { "value": "Jane Smith", "references": [ "5b8865b9-1a81-46df-bcf7-0bdbed9130dc" ] }, "relationship_to_patient": { "value": "Spouse", "references": [ "5b8865b9-1a81-46df-bcf7-0bdbed9130dc" ] } } } ``` -------------------------------- ### Initialize ADE Client for EU Deployment (Python, TypeScript) Source: https://docs.landing.ai/ade/ade-eu Demonstrates how to initialize the LandingAIADE client for the EU deployment in both Python and TypeScript. This involves setting the 'environment' parameter to 'eu' for Python or providing an options object with 'environment: "eu"' for TypeScript. Ensure the landingai-ade library is installed. ```python from landingai_ade import LandingAIADE client = LandingAIADE( environment="eu", ) ``` ```typescript import LandingAIADE from "landingai-ade"; const client = new LandingAIADE({ environment: "eu" }); ``` -------------------------------- ### Install p-limit for Rate Limiting (Bash) Source: https://docs.landing.ai/ade/ade-parse-async-sample Installs the 'p-limit' npm package, which is used to control the concurrency of asynchronous operations and prevent hitting API rate limits. ```bash npm install p-limit ``` -------------------------------- ### Initialize and Use ParseConfig in Python Source: https://docs.landing.ai/ade/ade-parseconfig Demonstrates how to instantiate a ParseConfig object with specific settings and pass it to the parse function to process a document. ```python from agentic_doc.parse import parse from agentic_doc.config import ParseConfig # Set up a configuration object config = ParseConfig( api_key="your-api-key", include_marginalia=False, include_metadata_in_markdown=True, split_size=5, ) # Pass the configuration object and parse the file using those settings results = parse("path/to/file.pdf", config=config) ``` -------------------------------- ### Install Zod for Type-Safe Extraction Source: https://docs.landing.ai/ade/ade-typescript Installs the Zod library, which enables type-safe schema definition and runtime validation for extracted data. This is a prerequisite for using Zod with Landing AI ADE. ```bash npm install zod ``` -------------------------------- ### Create and Monitor a Parse Job in Python Source: https://docs.landing.ai/ade/ade-python This snippet shows how to create a parsing job, monitor its status until completion, and access the parsed Markdown data. It requires the 'landingai_ade' library and a document path. ```python from pathlib import Path from landingai_ade import LandingAIADE import time client = LandingAIADE() # Step 1: Create a parse job job = client.parse_jobs.create( document=Path("/path/to/file/document"), model="dpt-2-latest" ) job_id = job.job_id print(f"Job {job_id} created.") # Step 2: Get the parsing results while True: response = client.parse_jobs.get(job_id) if response.status == "completed": print(f"Job {job_id} completed.") break print(f"Job {job_id}: {response.status} ({response.progress * 100:.0f}% complete)") time.sleep(5) # Step 3: Access the parsed data print("Global markdown:", response.data.markdown[:200] + "...") print(f"Number of chunks: {len(response.data.chunks)}") # Save Markdown output (useful if you plan to run extract on the Markdown) with open("output.md", "w", encoding="utf-8") as f: f.write(response.data.markdown) ``` -------------------------------- ### Set Custom Split Parameters (TypeScript) Source: https://docs.landing.ai/ade/ade-typescript Illustrates how to use the `split` method with specific optional parameters to customize the splitting behavior. This example shows how to specify a particular model version for the split operation. The `landingai-ade` library is necessary. ```typescript import LandingAIADE from "landingai-ade"; import fs from "fs"; const client = new LandingAIADE(); const splitResponse = await client.split({ split_class: [ { name: "Section A", description: "Introduction section" }, { name: "Section B", description: "Main content section" } ], markdown: fs.createReadStream("/path/to/parsed_output.md"), model: "split-20251105" // Use a specific model version }); ``` -------------------------------- ### Simple Schema Extraction Metadata Example (Table Cells) Source: https://docs.landing.ai/ade/ade-extract-response Example of 'extraction_metadata' for a simple schema when data is extracted from table cells. It shows the value and table cell IDs (e.g., '0-u') as references. ```json { "employee_name": { "value": "JANE HARPER", "references": [ "75a62de4-5120-44bf-a6dd-b2aa63db18c6" ] }, "gross_pay": { "value": 452.43, "references": [ "0-u" ] } } ``` -------------------------------- ### Configure API Key Environment Variable Source: https://docs.landing.ai/ade/ade-python Sets the required VISION_AGENT_API_KEY environment variable for library authentication. ```bash export VISION_AGENT_API_KEY= ``` -------------------------------- ### Example AI Job Response Data (JSON) Source: https://docs.landing.ai/ade/ade-parse-async This is an example of the JSON data structure that might be returned by an AI job, including status, received time, progress, and nested data containing markdown content. ```json { "job_id": "cmfx7w34q0000wcrdaaz45miu", "status": "completed", "received_at": 1758671983, "progress": 1.0, "org_id": null, "version": "latest", "data": { "markdown": "\n\nSummary : This image is a logo for the website USARAD.com, featuring stylized text over a blue globe with network-like lines.\n\nlogo: USARAD.com\n\nCompany Name & Tagline :\n • The logo displays \"USARAD.com\" as the main text.\n • \"USA\" is rendered in white with a blue outline and a pattern of stars.\n • \"RAD\" is in bold red uppercase letters.\n • \".com\" is in smaller white text with a blue outline, positioned to the right of \"RAD\".\n\nGraphic Elements :\n • The background is a blue globe with visible continents (North and South America, parts of Europe and Africa).\n • The globe features light blue intersecting lines, suggesting global connectivity or a network.\n • The logo has a slight shadow beneath the globe, giving a three-dimensional effect.\n\nLayout & Placement :\n • \"USARAD.com\" text is superimposed across the front of the globe, slightly angled.\n • The text is centered horizontally on the globe.\n\nAnalysis :\n • The logo combines patriotic elements (stars, \"USA\") with a global and technological theme (networked globe), likely representing a US-based radiology or medical imaging company with international reach.\n\n\n\n2601 E. Oakland Park Blvd, Suite 102 Ft. Lauderdale, FL 33306 Phone: 888.886.5238 Fax: 888.886.5221\n\n\n\nPatient: DOE, JOHN\nMRN : JD4USARAD\nReferring Physician: DR. DAVID LIVESEY\n\n\n\nExam Date: 05/20/2010\nDOB: 01/01/1961\nFAX: (305) 418-8166\n\n\n\nMRI OF THE LUMBAR SPINE WITH AND WITHOUT CONTRAST\n\n\n\nPROCEDURE:\nMRI of lumbosacral spine without/with IV contrast.\n\n\n\nINDICATION:\nRadiculopathy post L2-L3 fusion, question incomplete fusion. Persistent symptoms.\n\n\n\nCOMPARISON:\nNone.\n\n\n\nTECHNIQUE:\nMultiplanar and multi-sequence imaging of the lumbosacral spine without/with intravenous contrast using a 0.3T MRI scanner.\n\n\n\nFINDINGS:\nPostoperative findings of posterior intrapedicular spinal fusion at L2-L3 noted. The L2-L3 disk is preserved. Enhancing peridural fibrosis noted at L2-L3 level mildly deforming the thecal sac with dominant extrinsic impression on the right lateral thecal sac. Non enhancing cystic foci noted along the posterior elements representing small pseudomeningoceles. Postoperative fusion and laminectomy noted at L4-L5 level with osseous fusion anteriorly. Osseous hypertrophy of the posterior elements noted at L4 and L5. Lumbar lordosis is decreased. Multilevel endplate, disk and facet degenerative changes noted. Conus medullaris terminates at approximately mid L1 vertebral body level.\n\n\n\nL1-L2 shows moderate broad-based disc bulging contributing to mild to moderate left greater than right neuroforamina narrowing. Spinal canal is grossly patent. Approximately 2 mm L1 on L2 retrolisthesis noted.\n\n\n\nL2-L3 shows moderate nonenhancing bi foraminal broad-based disk bulging contributing to mild-to-moderate right greater than left neural foramina narrowing. Moderate acquired spinal canal stenosis noted due to enhancing peridural fibrosis with asymmetric more focal extrinsic impression on the right lateral ventral thecal sac. Negligible spondylolisthesis of L2 on L3 noted.\n\n = { chunkText: [40, 167, 69], chunkTable: [0, 123, 255], chunkMarginalia: [111, 66, 193], chunkFigure: [255, 0, 255], chunkLogo: [144, 238, 144], chunkCard: [255, 165, 0], chunkAttestation: [0, 255, 255], chunkScanCode: [255, 193, 7], chunkForm: [220, 20, 60], tableCell: [173, 216, 230], table: [70, 130, 180], }; function rgbToString(rgb: [number, number, number]): string { return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]}`; } ``` -------------------------------- ### Set API Key in Notebooks (IPython Magic Command) Source: https://docs.landing.ai/ade/agentic-api-key Sets the VISION_AGENT_API_KEY environment variable within an IPython-based notebook session using the %env magic command. This is session-specific and the key will be visible in the notebook file. ```python %env VISION_AGENT_API_KEY=your_api_key_here ``` -------------------------------- ### GET /v1/ade/parse/jobs/{job_id} Source: https://docs.landing.ai/ade/ade-parse-troubleshoot Retrieves the status and results of a specific asynchronous parsing job using its job ID. ```APIDOC ## GET /v1/ade/parse/jobs/{job_id} ### Description Retrieves the status and results of a specific asynchronous parsing job using its job ID. ### Method GET ### Endpoint /v1/ade/parse/jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the parsing job. ### Response #### Success Response (200) - **job_id** (string) - The unique identifier for the parsing job. - **status** (string) - The current status of the job (e.g., "completed", "failed", "processing"). - **parsed_content** (object) - The parsed content of the document (if job is completed). - **error_message** (string) - Description of the error if the job failed. #### Response Example ```json { "job_id": "job_abc123", "status": "completed", "parsed_content": { "pages": [ { "page_number": 1, "content": "This is the content of page 1." } ] } } ``` #### Error Responses - **400 Bad Request**: Invalid job ID format. - **401 Unauthorized**: Missing or invalid API key. - **404 Not Found**: Job with the specified ID does not exist. - **429 Too Many Requests**: Rate limit exceeded. ``` -------------------------------- ### GET /parse_jobs/{job_id} Source: https://docs.landing.ai/ade/ade-python Retrieves the status and results of a specific parsing job. ```APIDOC ## GET /parse_jobs/{job_id} ### Description Polls the status of a parsing job and retrieves the parsed data once completed. ### Method GET ### Endpoint /parse_jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The ID of the job to retrieve. ### Response #### Success Response (200) - **status** (string) - Current status of the job. - **data** (object) - Contains markdown, chunks, and metadata. #### Response Example { "status": "completed", "data": { "markdown": "# Document Title...", "chunks": [], "metadata": {} } } ``` -------------------------------- ### Initialize Landing AI ADE Client (TypeScript) Source: https://docs.landing.ai/ade/ade-parse-save-chunks-images-sample Initializes the Landing AI ADE client. This client is used to interact with the ADE API for document parsing. It automatically picks up the API key from the VISION_AGENT_API_KEY environment variable, simplifying authentication. ```typescript // Initialize client (uses the API key from the VISION_AGENT_API_KEY environment variable) const client = new LandingAIADE(); ``` -------------------------------- ### GET /v1/ade/parse/jobs/{job_id} Source: https://docs.landing.ai/ade/ade-parse-async Retrieves the current status and metadata of a specific parse job. ```APIDOC ## GET /v1/ade/parse/jobs/{job_id} ### Description Poll this endpoint to check the status of a previously submitted parse job. ### Method GET ### Endpoint /v1/ade/parse/jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique ID of the parse job. ### Response #### Success Response (200) - **status** (string) - Current status (e.g., pending, completed, failed). - **output_url** (string) - The location of the parsed output if completed. #### Response Example { "job_id": "job_12345", "status": "completed", "output_url": "https://s3.amazonaws.com/bucket/output.md" } ``` -------------------------------- ### Parse document and extract chunks as images Source: https://docs.landing.ai/ade/ade-parse-save-chunks-images-sample This script initializes the LandingAI ADE client, parses a document, and iterates through chunks to crop and save them as PNG files. It handles PDF rendering and image processing using libraries like PIL/pymupdf in Python and canvas/pdf-to-img in TypeScript. ```python from pathlib import Path from datetime import datetime from landingai_ade import LandingAIADE from PIL import Image import pymupdf def save_chunks_as_images(parse_response, document_path, output_base_dir="groundings"): timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") document_name = Path(document_path).stem output_dir = Path(output_base_dir) / f"{document_name}_{timestamp}" def save_page_chunks(image, chunks, page_num): img_width, img_height = image.size page_dir = output_dir / f"page_{page_num}" page_dir.mkdir(parents=True, exist_ok=True) for chunk in chunks: if chunk.grounding.page != page_num: continue box = chunk.grounding.box x1, y1 = int(box.left * img_width), int(box.top * img_height) x2, y2 = int(box.right * img_width), int(box.bottom * img_height) chunk_img = image.crop((x1, y1, x2, y2)) chunk_img.save(page_dir / f"{chunk.type}.{chunk.id}.png") if document_path.suffix.lower() == '.pdf': pdf = pymupdf.open(document_path) for page_num in range(len(pdf)): page = pdf[page_num] pix = page.get_pixmap(matrix=pymupdf.Matrix(2, 2)) img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples) save_page_chunks(img, parse_response.chunks, page_num) pdf.close() else: img = Image.open(document_path).convert("RGB") save_page_chunks(img, parse_response.chunks, 0) return output_dir client = LandingAIADE() document_path = Path("/path/to/file/document") parse_response = client.parse(document=document_path, model="dpt-2-latest") save_chunks_as_images(parse_response, document_path) ``` ```typescript import LandingAIADE from "landingai-ade"; import fs from "fs"; import path from "path"; import { createCanvas, loadImage } from "canvas"; async function saveChunksAsImages(parseResponse: any, documentPath: string, outputBaseDir: string = "groundings") { const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, -5); const documentName = path.basename(documentPath, path.extname(documentPath)); const outputDir = path.join(outputBaseDir, `${documentName}_${timestamp}`); async function savePageChunks(imageBuffer: Buffer, chunks: any[], pageNum: number) { const image = await loadImage(imageBuffer); const pageDir = path.join(outputDir, `page_${pageNum}`); if (!fs.existsSync(pageDir)) fs.mkdirSync(pageDir, { recursive: true }); for (const chunk of chunks) { if (chunk.grounding.page !== pageNum) continue; const box = chunk.grounding.box; const x1 = Math.floor(box.left * image.width); const y1 = Math.floor(box.top * image.height); const x2 = Math.floor(box.right * image.width); const y2 = Math.floor(box.bottom * image.height); const canvas = createCanvas(x2 - x1, y2 - y1); const ctx = canvas.getContext("2d"); ctx.drawImage(image, x1, y1, x2 - x1, y2 - y1, 0, 0, x2 - x1, y2 - y1); fs.writeFileSync(path.join(pageDir, `${chunk.type}.${chunk.id}.png`), canvas.toBuffer()); } } } ``` -------------------------------- ### GET /documents/splits Source: https://docs.landing.ai/ade/ade-json-response Configures how a document is segmented into splits. Omit the parameter for a full document return or set to 'page' for page-level segmentation. ```APIDOC ## GET /documents/splits ### Description Controls the segmentation of the document. If the split parameter is omitted, the API returns the entire document as one split. If set to 'page', the API returns one split per page. ### Method GET ### Endpoint /documents/splits ### Parameters #### Query Parameters - **split** (string) - Optional - Defines the splitting strategy. Options: 'page' or omit for full document. ### Request Example GET /documents/splits?split=page ### Response #### Success Response (200) - **splits** (array) - List of document segments containing markdown and chunk identifiers. #### Response Example { "splits": [ { "class": "page", "identifier": "page_0", "pages": [0], "markdown": "...", "chunks": ["chunk-id-1"] } ] } ``` -------------------------------- ### Visualize Parsed Document with Default Settings (Python) Source: https://docs.landing.ai/ade/ade-visualize This Python script demonstrates how to visualize parsed document results using the default settings provided by the `viz_parsed_document` function. It requires the `agentic_doc` library and takes a document path and output directory as input. ```python from agentic_doc.parse import parse from agentic_doc.utils import viz_parsed_document # Define the document path and output directory doc_path = "path/to/document.pdf" output_dir = "path/to/save/visualizations" # Parse the document (returns a list of parsed documents) results = parse(doc_path) parsed_doc = results[0] # Get the first parsed document # Create visualizations with default settings images = viz_parsed_document( doc_path, parsed_doc, output_dir=output_dir ) ```