diff options
| author | sigoden <sigoden@gmail.com> | 2024-11-27 09:16:06 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-27 09:16:06 +0800 |
| commit | 2003159d322a96165ab949051c004c456de5be11 (patch) | |
| tree | dc3c7f8e1850267ba24d1a3bf9a76fdac4366b6a /src/config | |
| parent | 6f60ad47535b75064a79331c22758d86e6e46d4f (diff) | |
| download | aichat-2003159d322a96165ab949051c004c456de5be11.tar.gz | |
feat: handle Ctrl+C during every spinner in REPL (#1014)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/input.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/config/input.rs b/src/config/input.rs index 5db172f..c527cfb 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -63,7 +63,6 @@ impl Input { paths: Vec<String>, role: Option<Role>, ) -> Result<Self> { - let spinner = create_spinner("Loading files").await; let mut raw_paths = vec![]; let mut local_paths = vec![]; let mut remote_urls = vec![]; @@ -82,7 +81,6 @@ impl Input { } } let ret = load_documents(config, local_paths, remote_urls).await; - spinner.stop(); let (files, medias, data_urls) = ret.context("Failed to load files")?; let mut texts = vec![]; if !raw_text.is_empty() { @@ -112,6 +110,21 @@ impl Input { }) } + pub async fn from_files_with_spinner( + config: &GlobalConfig, + raw_text: &str, + paths: Vec<String>, + role: Option<Role>, + abort_signal: AbortSignal, + ) -> Result<Self> { + abortable_run_with_spinner( + Input::from_files(config, raw_text, paths, role), + "Loading files", + abort_signal, + ) + .await + } + pub fn is_empty(&self) -> bool { self.text.is_empty() && self.medias.is_empty() } |
