diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-02 23:19:59 +0800 |
|---|---|---|
| committer | sigoden <sigoden@gmail.com> | 2023-03-02 23:22:06 +0800 |
| commit | 48ebf1895df934b900e12d4c9955829e99babe75 (patch) | |
| tree | efbb124138e4368164248558586ed86070af6a03 | |
| parent | 57844638ce504f1a69eb770f27bbafb7077ccb19 (diff) | |
| download | aichat-48ebf1895df934b900e12d4c9955829e99babe75.tar.gz | |
feat: remove the first two newlines
| -rw-r--r-- | src/main.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index eb88226..b7e3f23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -261,6 +261,7 @@ async fn handle_input(client: &Client, config: &Config, text: &str) -> Result<() return Ok(()); } let mut stream = acquire_stream(client, config, text).await?; + let mut virgin = true; while let Some(part) = stream.next().await { let chunk = part?.data; if chunk == "[DONE]" { @@ -272,7 +273,15 @@ async fn handle_input(client: &Client, config: &Config, text: &str) -> Result<() let text = data["choices"][0]["delta"]["content"] .as_str() .unwrap_or_default(); - + if text.is_empty() { + continue; + } + if virgin { + virgin = false; + if text == "\n\n" { + continue; + } + } print!("{text}"); stdout().flush().unwrap(); } |
