File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ default = ["default-tls"]
14
14
rustls = [" reqwest/rustls-tls" , " tokio-tungstenite/rustls-tls-webpki-roots" ]
15
15
default-tls = [" reqwest/default-tls" , " tokio-tungstenite/native-tls" ]
16
16
17
+ [dependencies ]
18
+ tracing = " 0.1.41"
19
+
17
20
[dependencies .reqwest ]
18
21
version = " 0.12"
19
22
default-features = false
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ pub struct OpenAIClientBuilder {
62
62
headers : Option < HeaderMap > ,
63
63
}
64
64
65
+ #[ derive( Debug ) ]
65
66
pub struct OpenAIClient {
66
67
api_endpoint : String ,
67
68
api_key : String ,
@@ -179,9 +180,20 @@ impl OpenAIClient {
179
180
path : & str ,
180
181
body : & impl serde:: ser:: Serialize ,
181
182
) -> 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 ?;
185
197
self . handle_response ( response) . await
186
198
}
187
199
You can’t perform that action at this time.
0 commit comments