Home Explore Blog Models CI



ragit

docs/commands/merge.txt
218a744398f0d7071aae14815b413052e2ba9a0482502f720000000300000af0
rag-merge(1)
==========

NAME
----
rag-merge - Merge another knowledge-base into the current base

SYNOPSIS
--------
[verse]
'rag merge' <path> [--prefix <path>]
            [--force | -f | --ignore | --interactive | --reject] [--quiet | -q]

DESCRIPTION
-----------
It has 2 use cases: merging another complete knowledge-base, merging 2
half-built knowledge-bases and continue building.

1. Merging 2 complete knowledge-bases

Let's say you have cloned 2 knowledge-bases: `rag clone https://ragit.baehyunsol.com/sample/git`
and `rag clone https://ragit.baehyunsol.com/sample/ragit`.
It would create 2 directories `git/` and `ragit/`, and each is a complete
knowledge-base. If you wanna know about git, you `cd git` and
`rag query <QUERY>`. Or, you can `cd ragit` and ask how ragit works. But this
is not ergonomic. If you have 10 different topics, there would be 10 different
directories and you would have to change directory each time.

That's where `rag merge` shines. Below is how it works.

1) run `mkdir merged; cd merged; rag init` to create an empty knowledge-base
2) run `rag merge ../git/ --prefix=git` and
   `rag merge ../ragit/ --prefix=ragit` to merge the 2 knowledge-bases.

When you merge a base, it reads the list of processed files of the base, then
copies all the chunks of the processed files. Since it identifies chunks based
on paths, it's easy to introduce collisions. For example, if both
knowledge-bases have a file `doc/index.txt`, there's no way to distinguish the
two. That's why you need `--prefix`. It adds prefixes to the paths. For example,
if `--prefix=git` is enabled, `doc/index.txt` of the knowledge-base will be
copied to `git/doc/index.txt`. Giving appropriate prefixes makes the lives of you
(RAG user), LLM and the engine easier.

2. Merging 2 half-built knowledge-bases and continue building

This feature is still under construction.

OPTIONS
-------
--prefix <path>::
        It adds a prefix to the files in the other knowledge-base. For
        example, if there's a file `/src/doc.txt` in the other
        knowledge-base, and `--prefix=other`, the file will be saved at
        `other/src/doc.txt` in the current knowledge-base.

--force::
        If a file in the other knowledge-base already exists in the current
        knowledge-base, it overwrites the current version with the new one.

--ignore::
        If a file in the other knowledge-base already exists in the current
        knowledge-base, it ignores the new one and keeps the old one.

--interactive::
        If a file in the other knowledge-base already exists in the current
        knowledge-base, it asks you if it should overwrite or not.

--reject::
        If any file in the other knowledge-base already exists in the current
        knowledge-base, it doesn't merge the bases.

Chunks
09f98540 (1st chunk of `docs/commands/merge.txt`)
Title: Rag Merge Command
Summary
The rag-merge command is used to merge another knowledge-base into the current base, allowing users to combine and manage multiple knowledge-bases efficiently, with options for handling conflicts and customizing the merge process.