diff options
| author | Anthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com> | 2023-07-09 20:07:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-10 11:07:09 +0800 |
| commit | 97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb (patch) | |
| tree | c19390877425fa50049761e8ee6bc93f21c46f56 /src/client.rs | |
| parent | ec51b84290215d11d5045de8baa9b89f2447b1e9 (diff) | |
| download | aichat-97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb.tar.gz | |
fix: minor code cleanup and pedantic lints (#134)
Diffstat (limited to 'src/client.rs')
| -rw-r--r-- | src/client.rs | 18 |
1 files changed, 9 insertions, 9 deletions
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(()) |
