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,54 @@
```go title="cli_with_config.go"
package main
import (
"encoding/json"
"fmt"
"os/exec"
)
type ExtractionResult struct {
Content string `json:"content"`
Format string `json:"format"`
Languages []string `json:"languages"`
}
func extractWithConfig(filePath string, configPath string) (*ExtractionResult, error) {
cmd := exec.Command(
"kreuzberg",
"extract",
filePath,
"--config",
configPath,
"--format",
"json",
)
output, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("CLI error: %w, output: %s", err, string(output))
}
var result ExtractionResult
if err := json.Unmarshal(output, &result); err != nil {
return nil, fmt.Errorf("JSON parse error: %w", err)
}
return &result, nil
}
func main() {
configFile := "kreuzberg.toml"
document := "document.pdf"
fmt.Printf("Extracting %s with config %s\n", document, configFile)
result, err := extractWithConfig(document, configFile)
if err != nil {
panic(err)
}
fmt.Printf("Content length: %d\n", len(result.Content))
fmt.Printf("Format: %s\n", result.Format)
fmt.Printf("Languages: %v\n", result.Languages)
}
```