This commit is contained in:
25
docs/snippets/python/advanced/token_reduction_example.md
Normal file
25
docs/snippets/python/advanced/token_reduction_example.md
Normal file
@@ -0,0 +1,25 @@
|
||||
```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())
|
||||
```
|
||||
Reference in New Issue
Block a user