From 97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb Mon Sep 17 00:00:00 2001 From: Anthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sun, 9 Jul 2023 20:07:09 -0700 Subject: fix: minor code cleanup and pedantic lints (#134) --- src/client.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/client.rs') diff --git a/src/client.rs b/src/client.rs index d366509..74871a0 100644 --- a/src/client.rs +++ b/src/client.rs @@ -12,6 +12,7 @@ use tokio::time::sleep; const API_URL: &str = "https://api.openai.com/v1/chat/completions"; +#[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct ChatGptClient { config: SharedConfig, @@ -106,16 +107,15 @@ impl ChatGptClient { let chunk = part?.data; if chunk == "[DONE]" { break; - } else { - let data: Value = serde_json::from_str(&chunk)?; - let text = data["choices"][0]["delta"]["content"] - .as_str() - .unwrap_or_default(); - if text.is_empty() { - continue; - } - handler.text(text)?; } + let data: Value = serde_json::from_str(&chunk)?; + let text = data["choices"][0]["delta"]["content"] + .as_str() + .unwrap_or_default(); + if text.is_empty() { + continue; + } + handler.text(text)?; } Ok(()) -- cgit v1.2.3