Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
linusbierhoff committed Oct 9, 2024
1 parent ccef047 commit fd80079
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions async-openai/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,13 @@ impl<C: Config> Client<C> {
.await
.map_err(OpenAIError::Reqwest)
.map_err(backoff::Error::Permanent)?;
tracing::debug!("Response: {:?}", response);
let status = response.status();
let bytes = response
.bytes()
.await
.map_err(OpenAIError::Reqwest)
.map_err(backoff::Error::Permanent)?;

tracing::debug!("Response: {:?}", str::from_utf8(&bytes));
// Deserialize response body from either error object or actual response object
if !status.is_success() {
let wrapped_error: WrappedError = serde_json::from_slice(bytes.as_ref())
Expand Down Expand Up @@ -351,7 +350,7 @@ impl<C: Config> Client<C> {
Fut: core::future::Future<Output = Result<reqwest::Request, OpenAIError>>,
{
let bytes = self.execute_raw(request_maker).await?;
tracing::debug!("Response: {:?}", str::from_utf8(&bytes));

let response: O = serde_json::from_slice(bytes.as_ref())
.map_err(|e| map_deserialization_error(e, bytes.as_ref()))?;

Expand Down

0 comments on commit fd80079

Please sign in to comment.