Skip to content

Commit

Permalink
chore: log openai completion error
Browse files Browse the repository at this point in the history
  • Loading branch information
zwpaper committed Nov 27, 2024
1 parent ff180aa commit 20dabf5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/http-api-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ollama-api-bindings = { path = "../ollama-api-bindings" }
async-openai.workspace = true
ratelimit = "0.10"
tokio.workspace = true
tracing.workspace = true

[dev-dependencies]
tokio = { workspace = true, features = ["rt", "macros"] }
11 changes: 9 additions & 2 deletions crates/http-api-bindings/src/completion/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use futures::{stream::BoxStream, StreamExt};
use reqwest_eventsource::{Event, EventSource};
use serde::{Deserialize, Serialize};
use tabby_inference::{CompletionOptions, CompletionStream};
use tracing::warn;

use super::split_fim_prompt;

Expand Down Expand Up @@ -100,8 +101,14 @@ impl CompletionStream for OpenAICompletionEngine {
}
}
}
Err(_) => {
// StreamEnd
Err(e) => {
match e {
reqwest_eventsource::Error::StreamEnded => {},
reqwest_eventsource::Error::InvalidStatusCode(code, resp) =>
warn!("Error in completion event source: {}, {}",
code, resp.text().await.unwrap_or_default().replace('\n', "")),
_ => warn!("Error in completion event source: {}", e),
}
break;
}
}
Expand Down

0 comments on commit 20dabf5

Please sign in to comment.