From 5f0840ac369da3400fdb095887001b27606b1ddb Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 17 Jan 2025 20:16:50 +0800 Subject: refactor: send all text instead of word-by-word in dry_run mode (#1088) --- src/client/common.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/client/common.rs') diff --git a/src/client/common.rs b/src/client/common.rs index e0ec861..a4e171a 100644 --- a/src/client/common.rs +++ b/src/client/common.rs @@ -76,11 +76,7 @@ pub trait Client: Sync + Send { ret = async { if self.global_config().read().dry_run { let content = input.echo_messages(); - let tokens = split_content(&content); - for token in tokens { - tokio::time::sleep(Duration::from_millis(10)).await; - handler.text(token)?; - } + handler.text(&content)?; return Ok(()); } let client = self.build_client()?; @@ -612,12 +608,3 @@ fn prompt_value_to_json(kind: &PromptKind, value: &str) -> Value { }, } } - -fn split_content(text: &str) -> Vec<&str> { - if text.is_ascii() { - text.split_inclusive(|c: char| c.is_ascii_whitespace()) - .collect() - } else { - unicode_segmentation::UnicodeSegmentation::graphemes(text, true).collect() - } -} -- cgit v1.2.3