Home Explore Blog CI



ragit

docs/commands/cat-file.txt
cb4dc5162846143f84559d560bbf1d2f6f51b75921b1a9b600000003000005f2
rag-cat-file(1)
==========

NAME
----
rag-cat-file - Show content of a file or a chunk

SYNOPSIS
--------
[verse]
'rag cat-file' [--json | -j] <uid>

DESCRIPTION
-----------
This command dump the contents of a file, a chunk or an image.

It doesn't always dump the exact content of the file, and that's intentional.
Some file readers modify the file content when chunking in order to give more
context to LLMs. For example, a csv-reader converts a csv file into a jsonl
file so that each chunk has more context. `cat-file` works by merging chunks
and it's not smart enough to re-construct the original file.

Also, some chunks have images, and there's no way to dump an image to stdout.
There are 2 ways that `cat-file` dumps images. If you `cat-file` a chunk or a
file, then it just dumps the uids of the images. For example, you have a chunk
"abcdef" and the chunk has an image "123abc". If you run `rag cat-file abcdef`,
the content will have "img_123abc". If you're building a gui on top of ragit,
make sure to replace the string "img_123abc" with the actual image.

If you're building a chunk viewer on top of `cat-file`, I recommend you use
`--json` option which clearly separates images and texts.

If you run "rag cat-file 123abc", where "123abc" is a uid of an image, it
dumps the bytes of the image file to stdout. If you're on a terminal,
you'll see bunch of unreadable characters. You have to redirect it to another
application. If it's "rag cat-file 123abc --json", it dumps the base64 encoding
of the bytes.

Chunks
7a351402 (1st chunk of `docs/commands/cat-file.txt`)
Title: Rag Cat File Command
Summary
The rag-cat-file command displays the content of a file, chunk, or image, with options to merge chunks, handle images, and output in JSON format for further processing or GUI integration, allowing for flexible content retrieval and manipulation, including dumping image bytes or base64 encoded strings, and providing a way to reconstruct file content, although it may not always reflect the original file due to modifications made by file readers.