diff options
| author | sigoden <sigoden@gmail.com> | 2024-09-14 20:10:49 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-14 20:10:49 +0800 |
| commit | beaf5946a98f1552763ff974942cc71ee531fe62 (patch) | |
| tree | 2588545daec3169cc93c389de4bbcb421a1cd60d /src/config/mod.rs | |
| parent | 6211d01a648e941fc69954d0855bcdcef98f27b9 (diff) | |
| download | aichat-beaf5946a98f1552763ff974942cc71ee531fe62.tar.gz | |
feat: add `.source rag` repl command (#871)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 4f7cfd7..cd2d4ad 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1199,6 +1199,16 @@ impl Config { Ok(()) } + pub fn rag_sources(config: &GlobalConfig) -> Result<String> { + match config.read().rag.as_ref() { + Some(rag) => match rag.get_last_sources() { + Some(v) => Ok(v), + None => bail!("No sources"), + }, + None => bail!("No RAG"), + } + } + pub fn rag_info(&self) -> Result<String> { if let Some(rag) = &self.rag { rag.export() @@ -1226,7 +1236,7 @@ impl Config { config.rag_min_score_keyword_search, ) }; - let embeddings = rag + let (embeddings, ids) = rag .search( text, top_k, @@ -1237,6 +1247,7 @@ impl Config { ) .await?; let text = config.read().rag_template(&embeddings, text); + rag.set_last_sources(&ids); Ok(text) } |
