Files
fil/docs/snippets/elixir/advanced/chunking_rag.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

646 B

config_json = Jason.encode!(%{
  "chunking" => %{
    "enabled" => true,
    "max_characters" => 512,
    "overlap" => 50,
    "respect_boundaries" => true
  }
})

{:ok, result} = Kreuzberg.extract_file_sync("document.pdf", "application/pdf", config_json)

# Prepare chunks for vector embedding and search
chunks_for_embedding = result.chunks
  |> Enum.map(fn chunk ->
    %{
      "id" => chunk["id"],
      "content" => chunk["content"],
      "metadata" => %{
        "page" => chunk["page"],
        "source" => "document.pdf"
      }
    }
  end)

IO.inspect(chunks_for_embedding, label: "Chunks Ready for RAG")