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,26 @@
```ruby title="basic_cli.rb"
require 'json'
require 'open3'
def extract_with_cli(file_path, output_format = 'text')
stdout, stderr, status = Open3.capture3(
'kreuzberg', 'extract', file_path, '--format', output_format
)
unless status.success?
warn "Error: #{stderr}"
exit 1
end
return JSON.parse(stdout) if output_format == 'json'
stdout
end
document = 'document.pdf'
text_output = extract_with_cli(document, 'text')
puts "Extracted: #{text_output.length} characters"
json_output = extract_with_cli(document, 'json')
puts "Format: #{json_output['format']}"
```

View File

@@ -0,0 +1,27 @@
```ruby title="cli_with_config.rb"
require 'json'
require 'open3'
def extract_with_config(file_path, config_path)
stdout, stderr, status = Open3.capture3(
'kreuzberg', 'extract', file_path, '--config', config_path, '--format', 'json'
)
unless status.success?
warn "Error: #{stderr}"
exit 1
end
JSON.parse(stdout)
end
config_file = 'kreuzberg.toml'
document = 'document.pdf'
puts "Extracting #{document} with config #{config_file}"
result = extract_with_config(document, config_file)
puts "Content length: #{result['content'].length}"
puts "Format: #{result['format']}"
puts "Languages: #{result['languages'].join(', ')}"
```