chore: import upstream snapshot with attribution
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
---
|
||||
title: "PaddleOCR"
|
||||
id: integrations-paddleocr
|
||||
description: "PaddleOCR integration for Haystack"
|
||||
slug: "/integrations-paddleocr"
|
||||
---
|
||||
|
||||
|
||||
## haystack_integrations.components.converters.paddleocr.paddleocr_vl_document_converter
|
||||
|
||||
### PaddleOCRVLDocumentConverter
|
||||
|
||||
Extracts text from documents using PaddleOCR's official document parsing API.
|
||||
|
||||
Uses `PaddleOCRClient` to parse documents via the PaddleOCR serving API.
|
||||
For more information, please refer to:
|
||||
https://www.paddleocr.ai/latest/en/version3.x/algorithm/PaddleOCR-VL/PaddleOCR-VL.html
|
||||
|
||||
**Usage Example:**
|
||||
|
||||
```python
|
||||
from haystack_integrations.components.converters.paddleocr import PaddleOCRVLDocumentConverter
|
||||
|
||||
converter = PaddleOCRVLDocumentConverter(
|
||||
base_url="http://xxxxx.aistudio-app.com",
|
||||
)
|
||||
result = converter.run(sources=["sample.pdf"])
|
||||
documents = result["documents"]
|
||||
raw_responses = result["raw_paddleocr_responses"]
|
||||
```
|
||||
|
||||
#### __init__
|
||||
|
||||
```python
|
||||
__init__(
|
||||
*,
|
||||
base_url: str | None = None,
|
||||
access_token: Secret = Secret.from_env_var(
|
||||
["PADDLEOCR_ACCESS_TOKEN", "AISTUDIO_ACCESS_TOKEN"]
|
||||
),
|
||||
model: Model | str = Model.PADDLE_OCR_VL_16,
|
||||
file_type: FileTypeInput = None,
|
||||
use_doc_orientation_classify: bool | None = False,
|
||||
use_doc_unwarping: bool | None = False,
|
||||
use_layout_detection: bool | None = None,
|
||||
use_chart_recognition: bool | None = None,
|
||||
use_seal_recognition: bool | None = None,
|
||||
use_ocr_for_image_block: bool | None = None,
|
||||
layout_threshold: float | dict | None = None,
|
||||
layout_nms: bool | None = None,
|
||||
layout_unclip_ratio: float | list | dict | None = None,
|
||||
layout_merge_bboxes_mode: str | dict | None = None,
|
||||
layout_shape_mode: str | None = None,
|
||||
prompt_label: str | None = None,
|
||||
format_block_content: bool | None = None,
|
||||
repetition_penalty: float | None = None,
|
||||
temperature: float | None = None,
|
||||
top_p: float | None = None,
|
||||
min_pixels: int | None = None,
|
||||
max_pixels: int | None = None,
|
||||
max_new_tokens: int | None = None,
|
||||
merge_layout_blocks: bool | None = None,
|
||||
markdown_ignore_labels: list[str] | None = None,
|
||||
vlm_extra_args: dict | None = None,
|
||||
prettify_markdown: bool | None = None,
|
||||
show_formula_number: bool | None = None,
|
||||
restructure_pages: bool | None = None,
|
||||
merge_tables: bool | None = None,
|
||||
relevel_titles: bool | None = None,
|
||||
visualize: bool | None = None,
|
||||
additional_params: dict[str, Any] | None = None
|
||||
) -> None
|
||||
```
|
||||
|
||||
Create a `PaddleOCRVLDocumentConverter` component.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- **base_url** (<code>str | None</code>) – Base URL for the PaddleOCR API. Falls back to `PADDLEOCR_BASE_URL`
|
||||
env var, then the SDK default.
|
||||
- **access_token** (<code>Secret</code>) – PaddleOCR access token. Falls back to `PADDLEOCR_ACCESS_TOKEN` env var.
|
||||
- **model** (<code>Model | str</code>) – Document parsing model. Defaults to `Model.PADDLE_OCR_VL_16`.
|
||||
- **file_type** (<code>FileTypeInput</code>) – "pdf", "image", or None for auto-detection.
|
||||
- **use_doc_orientation_classify** (<code>bool | None</code>) – Enable document orientation classification.
|
||||
- **use_doc_unwarping** (<code>bool | None</code>) – Enable text image unwarping.
|
||||
- **use_layout_detection** (<code>bool | None</code>) – Enable layout detection.
|
||||
- **use_chart_recognition** (<code>bool | None</code>) – Enable chart recognition.
|
||||
- **use_seal_recognition** (<code>bool | None</code>) – Enable seal recognition.
|
||||
- **use_ocr_for_image_block** (<code>bool | None</code>) – Recognize text in image blocks.
|
||||
- **layout_threshold** (<code>float | dict | None</code>) – Layout detection threshold.
|
||||
- **layout_nms** (<code>bool | None</code>) – Perform NMS on layout detection results.
|
||||
- **layout_unclip_ratio** (<code>float | list | dict | None</code>) – Layout unclip ratio.
|
||||
- **layout_merge_bboxes_mode** (<code>str | dict | None</code>) – Layout merge bounding boxes mode.
|
||||
- **layout_shape_mode** (<code>str | None</code>) – Layout shape mode.
|
||||
- **prompt_label** (<code>str | None</code>) – Prompt type for the VLM ("ocr", "formula", "table", "chart", "seal", "spotting").
|
||||
- **format_block_content** (<code>bool | None</code>) – Format block content.
|
||||
- **repetition_penalty** (<code>float | None</code>) – Repetition penalty for VLM sampling.
|
||||
- **temperature** (<code>float | None</code>) – Temperature for VLM sampling.
|
||||
- **top_p** (<code>float | None</code>) – Top-p for VLM sampling.
|
||||
- **min_pixels** (<code>int | None</code>) – Minimum pixels for VLM preprocessing.
|
||||
- **max_pixels** (<code>int | None</code>) – Maximum pixels for VLM preprocessing.
|
||||
- **max_new_tokens** (<code>int | None</code>) – Maximum tokens generated by the VLM.
|
||||
- **merge_layout_blocks** (<code>bool | None</code>) – Merge layout detection boxes for cross-column content.
|
||||
- **markdown_ignore_labels** (<code>list\[str\] | None</code>) – Layout labels to ignore in Markdown output.
|
||||
- **vlm_extra_args** (<code>dict | None</code>) – Extra configuration for the VLM.
|
||||
- **prettify_markdown** (<code>bool | None</code>) – Prettify output Markdown.
|
||||
- **show_formula_number** (<code>bool | None</code>) – Include formula numbers in Markdown output.
|
||||
- **restructure_pages** (<code>bool | None</code>) – Restructure results across multiple pages.
|
||||
- **merge_tables** (<code>bool | None</code>) – Merge tables across pages.
|
||||
- **relevel_titles** (<code>bool | None</code>) – Relevel titles.
|
||||
- **visualize** (<code>bool | None</code>) – Return visualization results.
|
||||
- **additional_params** (<code>dict\[str, Any\] | None</code>) – Extra options passed to `PaddleOCRVLOptions.extra_options`.
|
||||
|
||||
#### to_dict
|
||||
|
||||
```python
|
||||
to_dict() -> dict[str, Any]
|
||||
```
|
||||
|
||||
Serialize the component to a dictionary.
|
||||
|
||||
**Returns:**
|
||||
|
||||
- <code>dict\[str, Any\]</code> – Dictionary with serialized data.
|
||||
|
||||
#### from_dict
|
||||
|
||||
```python
|
||||
from_dict(data: dict[str, Any]) -> PaddleOCRVLDocumentConverter
|
||||
```
|
||||
|
||||
Deserialize the component from a dictionary.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- **data** (<code>dict\[str, Any\]</code>) – Dictionary to deserialize from.
|
||||
|
||||
**Returns:**
|
||||
|
||||
- <code>PaddleOCRVLDocumentConverter</code> – Deserialized component.
|
||||
|
||||
#### run
|
||||
|
||||
```python
|
||||
run(
|
||||
sources: list[str | Path | ByteStream],
|
||||
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
|
||||
) -> dict[str, Any]
|
||||
```
|
||||
|
||||
Convert image or PDF files to Documents.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- **sources** (<code>list\[str | Path | ByteStream\]</code>) – List of image or PDF file paths or ByteStream objects.
|
||||
- **meta** (<code>dict\[str, Any\] | list\[dict\[str, Any\]\] | None</code>) – Optional metadata to attach to the Documents. A single dict is applied
|
||||
to all documents; a list must match the number of sources.
|
||||
|
||||
**Returns:**
|
||||
|
||||
- <code>dict\[str, Any\]</code> – A dictionary with:
|
||||
- `documents`: List of created Documents.
|
||||
- `raw_paddleocr_responses`: List of raw PaddleOCR API responses.
|
||||
Reference in New Issue
Block a user