diff --git a/src/providers/azure/provider.rs b/src/providers/azure/provider.rs index 734ed12..faf8256 100644 --- a/src/providers/azure/provider.rs +++ b/src/providers/azure/provider.rs @@ -82,9 +82,16 @@ impl Provider for AzureProvider { .json() .await .map(ChatCompletionResponse::NonStream) - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) + .map_err(|e| { + eprintln!("Azure OpenAI API response error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + }) } } else { + eprintln!( + "Azure OpenAI API request error: {}", + response.text().await.unwrap() + ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) } } @@ -110,15 +117,22 @@ impl Provider for AzureProvider { .json(&payload) .send() .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + .map_err(|e| { + eprintln!("Azure OpenAI API request error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + })?; let status = response.status(); if status.is_success() { - response - .json() - .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) + response.json().await.map_err(|e| { + eprintln!("Azure OpenAI API response error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + }) } else { + eprintln!( + "Azure OpenAI API request error: {}", + response.text().await.unwrap() + ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) } } @@ -144,15 +158,22 @@ impl Provider for AzureProvider { .json(&payload) .send() .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + .map_err(|e| { + eprintln!("Azure OpenAI API request error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + })?; let status = response.status(); if status.is_success() { - response - .json() - .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) + response.json().await.map_err(|e| { + eprintln!("Azure OpenAI API response error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + }) } else { + eprintln!( + "Azure OpenAI API request error: {}", + response.text().await.unwrap() + ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) } } diff --git a/src/providers/openai/provider.rs b/src/providers/openai/provider.rs index cf68b61..057db38 100644 --- a/src/providers/openai/provider.rs +++ b/src/providers/openai/provider.rs @@ -86,15 +86,22 @@ impl Provider for OpenAIProvider { .json(&payload) .send() .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + .map_err(|e| { + eprintln!("OpenAI API request error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + })?; let status = response.status(); if status.is_success() { - response - .json() - .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) + response.json().await.map_err(|e| { + eprintln!("OpenAI API response error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + }) } else { + eprintln!( + "OpenAI API request error: {}", + response.text().await.unwrap() + ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) } } @@ -111,15 +118,22 @@ impl Provider for OpenAIProvider { .json(&payload) .send() .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + .map_err(|e| { + eprintln!("OpenAI API request error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + })?; let status = response.status(); if status.is_success() { - response - .json() - .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) + response.json().await.map_err(|e| { + eprintln!("OpenAI API response error: {}", e); + StatusCode::INTERNAL_SERVER_ERROR + }) } else { + eprintln!( + "OpenAI API request error: {}", + response.text().await.unwrap() + ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) } }