Skip to content

Commit

Permalink
fix(application): change error handling for api
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed May 15, 2024
1 parent b3ea09a commit b614cc6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/llm_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@ pub async fn generate_response(
let res = ollama
.generate(GenerationRequest::new(model.clone(), prompt))
.await;
res.map_err(|e| e.into()) // Map the Err variant to a Box<dyn std::error::Error>
match res {
Ok(res) => {
slog_scope::debug!("Response from ollama {}", res.response);
Ok(res)
},
Err(e) => {
slog_scope::error!("{}", e);
Err(e.into())
}
}
}

0 comments on commit b614cc6

Please sign in to comment.