summaryrefslogtreecommitdiffstats
path: root/src/client/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-10-27 09:33:34 +0800
committerGitHub <noreply@github.com>2023-10-27 09:33:34 +0800
commit47818159a7ca3910cdc6ed00109a331d2ac2f906 (patch)
tree967e28746d01e71a4227e441078613f0abdbded8 /src/client/mod.rs
parent2fad63be6a826db1340734b98e3d507660611bf6 (diff)
downloadaichat-47818159a7ca3910cdc6ed00109a331d2ac2f906.tar.gz
refactor: streaming input text in dry-run mode (#154)
Diffstat (limited to 'src/client/mod.rs')
-rw-r--r--src/client/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index bf83c60..1f9e66c 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -17,6 +17,7 @@ use crate::{
client::localai::LocalAIClient,
config::{Config, SharedConfig},
repl::{ReplyStreamHandler, SharedAbortSignal},
+ utils::split_text,
};
#[allow(clippy::struct_excessive_bools)]
@@ -92,7 +93,11 @@ pub trait Client {
tokio::select! {
ret = async {
if self.get_config().read().dry_run {
- handler.text(&self.get_config().read().echo_messages(content))?;
+ let words = split_text(content)?;
+ for word in words {
+ tokio::time::sleep(Duration::from_millis(25)).await;
+ handler.text(&self.get_config().read().echo_messages(&word))?;
+ }
return Ok(());
}
self.send_message_streaming_inner(content, handler).await