summaryrefslogtreecommitdiffstats
path: root/src/client/ollama.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-04-29 23:09:19 +0000
committersigoden <sigoden@gmail.com>2024-04-29 23:09:19 +0000
commit97f6d48c4240859a981ea994840fc68000514a43 (patch)
treec5b36a950797990367415b71d304d9cc1013f92b /src/client/ollama.rs
parent50eac8b59409f73655fc2b8cf8d783c6347209c3 (diff)
downloadaichat-97f6d48c4240859a981ea994840fc68000514a43.tar.gz
refactor: check res status code
Diffstat (limited to 'src/client/ollama.rs')
-rw-r--r--src/client/ollama.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/client/ollama.rs b/src/client/ollama.rs
index 158bbbe..eebf301 100644
--- a/src/client/ollama.rs
+++ b/src/client/ollama.rs
@@ -65,7 +65,7 @@ async fn send_message(builder: RequestBuilder) -> Result<(String, CompletionDeta
let res = builder.send().await?;
let status = res.status();
let data = res.json().await?;
- if status != 200 {
+ if !status.is_success() {
catch_error(&data, status.as_u16())?;
}
let text = data["message"]["content"]
@@ -77,7 +77,7 @@ async fn send_message(builder: RequestBuilder) -> Result<(String, CompletionDeta
async fn send_message_streaming(builder: RequestBuilder, handler: &mut SseHandler) -> Result<()> {
let res = builder.send().await?;
let status = res.status();
- if status != 200 {
+ if !status.is_success() {
let data = res.json().await?;
catch_error(&data, status.as_u16())?;
} else {