Skip to content

Commit c98efb5

Browse files
committed
added debugging
1 parent 4c97931 commit c98efb5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ default = ["default-tls"]
1414
rustls = ["reqwest/rustls-tls", "tokio-tungstenite/rustls-tls-webpki-roots"]
1515
default-tls = ["reqwest/default-tls", "tokio-tungstenite/native-tls"]
1616

17+
[dependencies]
18+
tracing = "0.1.41"
19+
1720
[dependencies.reqwest]
1821
version = "0.12"
1922
default-features = false

src/v1/api.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub struct OpenAIClientBuilder {
6262
headers: Option<HeaderMap>,
6363
}
6464

65+
#[derive(Debug)]
6566
pub struct OpenAIClient {
6667
api_endpoint: String,
6768
api_key: String,
@@ -179,9 +180,20 @@ impl OpenAIClient {
179180
path: &str,
180181
body: &impl serde::ser::Serialize,
181182
) -> Result<T, APIError> {
182-
let request = self.build_request(Method::POST, path).await;
183-
let request = request.json(body);
184-
let response = request.send().await?;
183+
let request_builder = self.build_request(Method::POST, path).await;
184+
let request_builder = request_builder.json(body);
185+
186+
// 💡 Convert to request to inspect it before sending
187+
let client = request_builder
188+
.try_clone()
189+
.expect("Cannot clone request builder")
190+
.build()
191+
.expect("Failed to build request");
192+
193+
// 🔍 Debug log: URL, headers, and optionally body
194+
tracing::debug!("🔵 URL: {}", client.url());
195+
tracing::debug!("🟢 Headers:\n{:#?}", client.headers());
196+
let response = request_builder.send().await?;
185197
self.handle_response(response).await
186198
}
187199

0 commit comments

Comments
 (0)