Files
fil/docs/snippets/python/advanced/token_reduction_example.md
Henrik Jess Nielsen b4c07d3693
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s
Nomad changes
2026-06-01 23:40:55 +02:00

26 lines
535 B
Markdown

```python title="Python"
import asyncio
from kreuzberg import (
ExtractionConfig,
TokenReductionConfig,
ReductionLevel,
extract_file,
)
async def main() -> None:
config: ExtractionConfig = ExtractionConfig(
token_reduction=TokenReductionConfig(
level=ReductionLevel.MODERATE,
preserve_markdown=True,
)
)
result = await extract_file("verbose_document.pdf", config=config)
print(f"Reduced content length: {len(result.content)} chars")
asyncio.run(main())
```