summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-11-08 18:26:38 +0800
committerGitHub <noreply@github.com>2023-11-08 18:26:38 +0800
commiteb30d90391ef73429589a98f34dfe4d3d88d0a38 (patch)
tree3ba569b16048a289d729262ffce475d610e51187 /src/repl/mod.rs
parenta8a504e0f07c2d1c725bace7f0affb468cf0622d (diff)
downloadaichat-eb30d90391ef73429589a98f34dfe4d3d88d0a38.tar.gz
refactor: improve render (#235)
* refactor: redesign render - if stdout is not terminal, just write reply text to stdout - rename repl_render_stream to markdown_stream - deprecate cmd_render_stream - use raw_stream to just print streaming reply text * optimize rendering error * optimize render_stream
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 8ffb36c..511e069 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -12,7 +12,6 @@ use crate::render::{render_error, render_stream};
use crate::utils::{create_abort_signal, set_text, AbortSignal};
use anyhow::{bail, Context, Result};
-use crossbeam::sync::WaitGroup;
use fancy_regex::Regex;
use lazy_static::lazy_static;
use reedline::Signal;
@@ -235,21 +234,11 @@ impl Repl {
return Ok(());
}
self.config.read().maybe_print_send_tokens(input);
- let wg = WaitGroup::new();
let client = init_client(&self.config)?;
- let ret = render_stream(
- input,
- client.as_ref(),
- &self.config,
- true,
- self.abort.clone(),
- wg.clone(),
- );
- wg.wait();
- let buffer = ret?;
- self.config.write().save_message(input, &buffer)?;
+ let output = render_stream(input, client.as_ref(), &self.config, self.abort.clone())?;
+ self.config.write().save_message(input, &output)?;
if self.config.read().auto_copy {
- let _ = self.copy(&buffer);
+ let _ = self.copy(&output);
}
Ok(())
}