Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
```python title="basic_cli.py"
import subprocess
import json
import sys
from pathlib import Path
def extract_with_cli(file_path: str, output_format: str = "text") -> str:
result = subprocess.run(
["kreuzberg", "extract", file_path, "--format", output_format],
capture_output=True,
text=True,
)
if result.returncode != 0:
print(f"Error: {result.stderr}", file=sys.stderr)
sys.exit(1)
if output_format == "json":
return json.loads(result.stdout)
return result.stdout
document = "document.pdf"
text_output = extract_with_cli(document, "text")
print(f"Extracted: {len(text_output)} characters")
json_output = extract_with_cli(document, "json")
print(f"Format: {json_output.get('format', 'unknown')}")
```

View File

@@ -0,0 +1,29 @@
```python title="cli_with_config.py"
import subprocess
import json
import sys
from pathlib import Path
def extract_with_config(file_path: str, config_path: str) -> dict:
result = subprocess.run(
["kreuzberg", "extract", file_path, "--config", config_path, "--format", "json"],
capture_output=True,
text=True,
)
if result.returncode != 0:
print(f"Error: {result.stderr}", file=sys.stderr)
sys.exit(1)
return json.loads(result.stdout)
config_file = Path("kreuzberg.toml")
document = "document.pdf"
print(f"Extracting {document} with config {config_file}")
result = extract_with_config(str(document), str(config_file))
print(f"Content length: {len(result.get('content', ''))}")
print(f"Format: {result.get('format')}")
print(f"Languages: {result.get('languages')}")
```