summaryrefslogtreecommitdiffstats
path: root/src/client.rs
diff options
context:
space:
mode:
authorAnthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com>2023-07-09 20:07:09 -0700
committerGitHub <noreply@github.com>2023-07-10 11:07:09 +0800
commit97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb (patch)
treec19390877425fa50049761e8ee6bc93f21c46f56 /src/client.rs
parentec51b84290215d11d5045de8baa9b89f2447b1e9 (diff)
downloadaichat-97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb.tar.gz
fix: minor code cleanup and pedantic lints (#134)
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs18
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(())