diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-25 12:55:38 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-25 12:55:38 +0800 |
| commit | 9f19108a7157db21e331c0b1c3df3f98611c1a80 (patch) | |
| tree | ab4fc6698f51bbbfc332de469467654c74e15f46 /src/rag/mod.rs | |
| parent | 2bc9607b00fa5f31ced08f78fe08fe71b923b152 (diff) | |
| download | aichat-9f19108a7157db21e331c0b1c3df3f98611c1a80.tar.gz | |
refactor: rag chunk contains path metadata (#647)
Diffstat (limited to 'src/rag/mod.rs')
| -rw-r--r-- | src/rag/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/rag/mod.rs b/src/rag/mod.rs index 3fdad02..ab7c3c7 100644 --- a/src/rag/mod.rs +++ b/src/rag/mod.rs @@ -262,8 +262,10 @@ impl Rag { ); let documents = load(&path, &extension) .with_context(|| format!("Failed to load file at '{path}'"))?; - let documents = - splitter.split_documents(&documents, &SplitterChunkHeaderOptions::default()); + let split_options = SplitterChunkHeaderOptions::default().with_chunk_header(&format!( + "<document_metadata>\npath: {path}\n</document_metadata>\n\n" + )); + let documents = splitter.split_documents(&documents, &split_options); rag_files.push(RagFile { path, documents }); progress( &progress_tx, |
