diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-26 08:18:58 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-26 08:18:58 +0800 |
| commit | 95bad975f4fb47fe86df1837660a1341009ea12a (patch) | |
| tree | 1d88411576d07d6e46311ac726a8577d1e5e38f2 /src/config | |
| parent | 34a6d13fb6e492860e1340ab7a97cbd1bdeb9d4d (diff) | |
| download | aichat-95bad975f4fb47fe86df1837660a1341009ea12a.tar.gz | |
feat: custom rag document loaders (#650)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 62ed28e..26c0bda 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -115,6 +115,8 @@ pub struct Config { pub rag_min_score_vector_search: f32, pub rag_min_score_keyword_search: f32, pub rag_min_score_rerank: f32, + #[serde(default)] + pub rag_document_loaders: HashMap<String, String>, pub rag_template: Option<String>, pub highlight: bool, @@ -174,6 +176,7 @@ impl Default for Config { rag_min_score_vector_search: 0.0, rag_min_score_keyword_search: 0.0, rag_min_score_rerank: 0.0, + rag_document_loaders: Default::default(), rag_template: None, save_session: None, @@ -229,6 +232,7 @@ impl Config { config.setup_model()?; config.setup_highlight(); config.setup_light_theme()?; + config.setup_rag_document_loaders(); Ok(config) } @@ -1440,6 +1444,19 @@ impl Config { }; Ok(()) } + + fn setup_rag_document_loaders(&mut self) { + [ + ("pdf", "pdftotext $1 -"), + ("docx", "pandoc --to plain $1"), + ("url", "curl -fsSL $1"), + ] + .into_iter() + .for_each(|(k, v)| { + let (k, v) = (k.to_string(), v.to_string()); + self.rag_document_loaders.entry(k).or_insert(v); + }); + } } #[derive(Debug, Clone, Deserialize, Default)] |
