Log a warning when ollama isn't available
This commit is contained in:
parent
3f6a641747
commit
2350d4b9cd
3 changed files with 10 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -10816,6 +10816,7 @@ dependencies = [
|
||||||
"http_client",
|
"http_client",
|
||||||
"inline_completion",
|
"inline_completion",
|
||||||
"language",
|
"language",
|
||||||
|
"log",
|
||||||
"project",
|
"project",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -27,6 +27,7 @@ gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
inline_completion.workspace = true
|
inline_completion.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
|
log.workspace = true
|
||||||
|
|
||||||
project.workspace = true
|
project.workspace = true
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
|
|
|
@ -411,7 +411,14 @@ pub async fn generate(
|
||||||
let serialized_request = serde_json::to_string(&request)?;
|
let serialized_request = serde_json::to_string(&request)?;
|
||||||
let request = request_builder.body(AsyncBody::from(serialized_request))?;
|
let request = request_builder.body(AsyncBody::from(serialized_request))?;
|
||||||
|
|
||||||
let mut response = client.send(request).await?;
|
let mut response = match client.send(request).await {
|
||||||
|
Ok(response) => response,
|
||||||
|
Err(err) => {
|
||||||
|
log::warn!("Ollama server unavailable at {}: {}", api_url, err);
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut body = String::new();
|
let mut body = String::new();
|
||||||
response.body_mut().read_to_string(&mut body).await?;
|
response.body_mut().read_to_string(&mut body).await?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue