diff options
| author | sigoden <sigoden@gmail.com> | 2024-04-25 14:03:16 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-25 14:03:16 +0800 |
| commit | a193710a7f88de12ef11c5a5c66a5591150fe247 (patch) | |
| tree | 937a64da3dad52706d155ac9191e324fd8648ccc /src/client/ollama.rs | |
| parent | 4db9b309803796bc5f996d0b3713344eb44207ec (diff) | |
| download | aichat-a193710a7f88de12ef11c5a5c66a5591150fe247.tar.gz | |
refactor: extract common catch_error (#437)
Diffstat (limited to 'src/client/ollama.rs')
| -rw-r--r-- | src/client/ollama.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/client/ollama.rs b/src/client/ollama.rs index 1394ced..f2340c6 100644 --- a/src/client/ollama.rs +++ b/src/client/ollama.rs @@ -1,6 +1,6 @@ use super::{ - message::*, Client, ExtraConfig, Model, ModelConfig, OllamaClient, PromptType, ReplyHandler, - SendData, + catch_error, message::*, Client, ExtraConfig, Model, ModelConfig, OllamaClient, PromptType, + ReplyHandler, SendData, }; use crate::utils::PromptKind; @@ -191,11 +191,3 @@ fn build_body(data: SendData, model: &Model) -> Result<Value> { Ok(body) } - -fn catch_error(data: &Value, status: u16) -> Result<()> { - debug!("Invalid response, status: {status}, data: {data}"); - if let Some(error) = data["error"].as_str() { - bail!("{error}"); - } - bail!("Invalid response, status: {status}, data: {data}"); -} |
