diff options
| author | sigoden <sigoden@gmail.com> | 2025-01-17 20:16:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-17 20:16:50 +0800 |
| commit | 5f0840ac369da3400fdb095887001b27606b1ddb (patch) | |
| tree | d16326635e48c353545f607c0e19ab0e03d930a5 /src/client/common.rs | |
| parent | 30dae5c12b81a6f92be138966d8930fa15612cb0 (diff) | |
| download | aichat-5f0840ac369da3400fdb095887001b27606b1ddb.tar.gz | |
refactor: send all text instead of word-by-word in dry_run mode (#1088)
Diffstat (limited to 'src/client/common.rs')
| -rw-r--r-- | src/client/common.rs | 15 |
1 files changed, 1 insertions, 14 deletions
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() - } -} |
