Skip to content

Commit e63f29a

Browse files
committed
feat: add extraction formats parameter to sdk
Signed-off-by: Aleš Kalfas <kalfas.ales@gmail.com>
1 parent 7f2b4c8 commit e63f29a

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

  • apps/agentstack-sdk-py/src/agentstack_sdk/platform
  • docs/agent-development

apps/agentstack-sdk-py/src/agentstack_sdk/platform/file.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
from agentstack_sdk.util.file import LoadedFile, LoadedFileWithUri, PlatformFileUrl
1717
from agentstack_sdk.util.utils import filter_dict
1818

19+
ExtractionFormatLiteral = typing.Literal["markdown", "vendor_specific_json"]
20+
1921

2022
class ExtractedFileInfo(pydantic.BaseModel):
2123
"""Information about an extracted file."""
2224

2325
file_id: str
24-
format: typing.Literal["markdown", "vendor_specific_json"] | None
26+
format: ExtractionFormatLiteral | None
2527

2628

2729
class Extraction(pydantic.BaseModel):
@@ -195,6 +197,7 @@ async def load_json_content(
195197
async def create_extraction(
196198
self: File | str,
197199
*,
200+
formats: list[ExtractionFormatLiteral] | None = None,
198201
client: PlatformClient | None = None,
199202
context_id: str | None | Literal["auto"] = "auto",
200203
) -> Extraction:
@@ -207,6 +210,7 @@ async def create_extraction(
207210
await platform_client.post(
208211
url=f"/api/v1/files/{file_id}/extraction",
209212
params=context_id and {"context_id": context_id},
213+
json={"settings": {"formats": formats}} if formats else None,
210214
)
211215
)
212216
.raise_for_status()

docs/agent-development/rag.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def extract_file(file: File):
9999

100100
#### Extraction Formats
101101

102-
Text extraction produces two extraction formats:
102+
Text extraction produces two extraction formats and you can request either subset by passing `formats` to `create_extraction` (e.g., `["markdown"]` if you only need plain text):
103103

104104
- __markdown__: The extracted text formatted as Markdown (`file.load_text_content()`)
105105
- __vendor_specific_json__: The Docling-specific JSON format containing document structure (`file.load_json_content()`)

0 commit comments

Comments
 (0)