diff options
| author | sigoden <sigoden@gmail.com> | 2023-11-08 18:26:38 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-08 18:26:38 +0800 |
| commit | eb30d90391ef73429589a98f34dfe4d3d88d0a38 (patch) | |
| tree | 3ba569b16048a289d729262ffce475d610e51187 /src/repl/mod.rs | |
| parent | a8a504e0f07c2d1c725bace7f0affb468cf0622d (diff) | |
| download | aichat-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.rs | 17 |
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(()) } |
