Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions datalab_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ def _build_conversion_result(self, result_data: Dict[str, Any], default_format:
runtime=result_data.get("runtime"),
cost_breakdown=result_data.get("cost_breakdown"),
evaluation=result_data.get("evaluation"),
extraction_mode=result_data.get("extraction_mode"),
extraction_score_average=result_data.get("extraction_score_average"),
segmentation_schema=result_data.get("segmentation_schema"),
)

async def _submit_and_poll(
Expand Down Expand Up @@ -801,6 +804,7 @@ async def create_document(
markdown: str,
output_format: str = "docx",
webhook_url: Optional[str] = None,
processing_location: Optional[str] = None,
save_output: Optional[Union[str, Path]] = None,
stream_response_to: Optional[Union[str, Path]] = None,
max_polls: int = 300,
Expand All @@ -818,6 +822,7 @@ async def create_document(
markdown: The markdown content to convert to a document
output_format: Output format (currently only 'docx')
webhook_url: Optional webhook URL for completion notification
processing_location: Optional residency region override (e.g. "us" or "eu")
save_output: Optional path to save the output file
stream_response_to: Optional path to stream raw JSON response to disk
max_polls: Maximum number of polling attempts
Expand All @@ -838,6 +843,8 @@ async def create_document(
}
if webhook_url:
payload["webhook_url"] = webhook_url
if processing_location is not None:
payload["processing_location"] = processing_location

initial_data = await self._submit_with_retry(
"/api/v1/create-document",
Expand Down Expand Up @@ -2395,6 +2402,7 @@ def create_document(
markdown: str,
output_format: str = "docx",
webhook_url: Optional[str] = None,
processing_location: Optional[str] = None,
save_output: Optional[Union[str, Path]] = None,
stream_response_to: Optional[Union[str, Path]] = None,
max_polls: int = 300,
Expand All @@ -2407,6 +2415,7 @@ def create_document(
markdown: The markdown content to convert to a document
output_format: Output format (currently only 'docx')
webhook_url: Optional webhook URL for completion notification
processing_location: Optional residency region override (e.g. "us" or "eu")
save_output: Optional path to save the output file
stream_response_to: Optional path to stream raw JSON response to disk
max_polls: Maximum number of polling attempts
Expand All @@ -2417,6 +2426,7 @@ def create_document(
markdown=markdown,
output_format=output_format,
webhook_url=webhook_url,
processing_location=processing_location,
save_output=save_output,
stream_response_to=stream_response_to,
max_polls=max_polls,
Expand Down
14 changes: 12 additions & 2 deletions datalab_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ProcessingOptions:
max_pages: Optional[int] = None
skip_cache: bool = False
page_range: Optional[str] = None
processing_location: Optional[str] = None # e.g. "us" or "eu"; overrides team default residency

def to_form_data(self) -> Dict[str, Any]:
"""Convert to form data format for API requests"""
Expand Down Expand Up @@ -48,12 +49,14 @@ class ConvertOptions(ProcessingOptions):
keep_spreadsheet_formatting: bool = False
webhook_url: Optional[str] = None
# Comma-separated list of extra features: 'track_changes', 'chart_understanding',
# 'table_row_bboxes', 'extract_links', 'infographic', 'new_block_types'
# 'table_cell_bboxes', 'list_item_bboxes', 'extract_links', 'infographic', 'new_block_types'
extras: Optional[str] = None
add_block_ids: bool = False # add block IDs to HTML output
include_markdown_in_chunks: bool = False # include markdown field in chunks/JSON output
token_efficient_markdown: bool = False # optimize markdown for LLM token usage
eval_rubric_id: Optional[int] = None # run evaluation rubric after conversion
word_bboxes: bool = False # predict per-word bounding boxes with confidence scores
merge_cross_page: bool = False # merge tables/paragraphs/lists split across pages (variable cost surcharge)

def to_form_data(self) -> Dict[str, Any]:
"""Convert to form data format for API requests"""
Expand Down Expand Up @@ -83,7 +86,8 @@ class ExtractOptions(ProcessingOptions):
schema_id: Optional[str] = None # ID of a saved extraction schema (e.g. sch_k8Hx9mP2nQ4v). Mutually exclusive with page_schema.
schema_version: Optional[int] = None # Version of the schema. Only valid with schema_id.
checkpoint_id: Optional[str] = None # From previous /convert with save_checkpoint=true
mode: str = "fast" # fast, balanced, accurate
mode: str = "fast" # Parse mode: fast, balanced, accurate
extraction_mode: Optional[str] = None # Extraction mode: "turbo", "fast", "balanced", or "accurate". Defaults to "balanced".
output_format: str = "markdown" # markdown, json, html, chunks
save_checkpoint: bool = False
webhook_url: Optional[str] = None
Expand All @@ -94,6 +98,9 @@ def to_form_data(self) -> Dict[str, Any]:
# When using schema_id, suppress the empty default page_schema
if self.schema_id and not self.page_schema:
form_data.pop("page_schema", None)
# Only send extraction_mode if explicitly set
if self.extraction_mode is None:
form_data.pop("extraction_mode", None)
return form_data


Expand Down Expand Up @@ -202,6 +209,9 @@ class ConversionResult:
runtime: Optional[float] = None
cost_breakdown: Optional[Dict[str, Any]] = None
evaluation: Optional[Dict[str, Any]] = None # Evaluation results when run_eval=true
extraction_mode: Optional[str] = None # Extraction mode used: 'turbo', 'fast', 'balanced', or 'accurate'
extraction_score_average: Optional[float] = None # Average confidence score (1-5) across extracted fields
segmentation_schema: Optional[str] = None # Segmentation schema echoed back from /segment requests

def save_output(
self, output_path: Union[str, Path], save_images: bool = True
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading