diff --git a/llm_client/src/clients/anthropic.rs b/llm_client/src/clients/anthropic.rs index ac28681ff..3c6e29cf4 100644 --- a/llm_client/src/clients/anthropic.rs +++ b/llm_client/src/clients/anthropic.rs @@ -482,6 +482,12 @@ impl AnthropicClient { return Err(LLMClientError::UnauthorizedAccess); } + if let Err(e) = response_stream.error_for_status_ref() { + let body = response_stream.text().await?; + println!("anthropic::err {body}"); + return Err(e.into()); + } + let mut event_source = response_stream.bytes_stream().eventsource(); // let event_next = event_source.next().await; @@ -755,6 +761,12 @@ impl LLMClient for AnthropicClient { return Err(LLMClientError::UnauthorizedAccess); } + if let Err(e) = response_stream.error_for_status_ref() { + let body = response_stream.text().await?; + println!("anthropic::err {body}"); + return Err(e.into()); + } + let mut event_source = response_stream.bytes_stream().eventsource(); let mut input_tokens = 0; @@ -893,6 +905,12 @@ impl LLMClient for AnthropicClient { return Err(LLMClientError::UnauthorizedAccess); } + if let Err(e) = response.error_for_status_ref() { + let body = response.text().await?; + println!("anthropic::err {body}"); + return Err(e.into()); + } + let mut response_stream = response.bytes_stream().eventsource(); let mut buffered_string = "".to_owned();