dynamo-llm 1.0.2

Dynamo LLM Library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
// SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

//! HTTP clients for streaming LLM responses with performance recording
//!
//! This module provides HTTP clients that leverage async-openai with BYOT (Bring Your Own Types)
//! feature to work with OpenAI-compatible APIs. The clients support recording streaming responses
//! for performance analysis.

use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
use std::time::Instant;

use async_trait::async_trait;
use derive_getters::Dissolve;
use dynamo_async_openai::{Client, config::OpenAIConfig, error::OpenAIError};
use futures::Stream;
use serde_json::Value;
use tokio_util::sync::CancellationToken;
use tracing;
use uuid::Uuid;

// Import our existing recording infrastructure
use crate::protocols::Annotated;
use crate::protocols::openai::chat_completions::{
    NvCreateChatCompletionRequest, NvCreateChatCompletionStreamResponse,
};
use dynamo_runtime::engine::{
    AsyncEngineContext, AsyncEngineContextProvider, AsyncEngineStream, Data, DataStream,
};

/// Configuration for HTTP clients
#[derive(Clone, Default)]
pub struct HttpClientConfig {
    /// OpenAI API configuration
    pub openai_config: OpenAIConfig,
    /// Whether to enable detailed logging
    pub verbose: bool,
}

/// Error types for HTTP clients
#[derive(Debug, thiserror::Error)]
pub enum HttpClientError {
    #[error("OpenAI API error: {0}")]
    OpenAI(#[from] OpenAIError),
    #[error("Request timeout")]
    Timeout,
    #[error("Request cancelled")]
    Cancelled,
    #[error("Invalid request: {0}")]
    InvalidRequest(String),
}

/// Context for HTTP client requests that supports cancellation
/// This bridges AsyncEngineContext and reqwest cancellation
#[derive(Clone)]
pub struct HttpRequestContext {
    /// Unique request identifier
    id: String,
    /// Tokio cancellation token for reqwest integration
    cancel_token: CancellationToken,
    /// When this context was created
    created_at: Instant,
    /// Whether the request has been stopped
    stopped: Arc<std::sync::atomic::AtomicBool>,
    /// Child contexts to be stopped if this is stopped
    child_context: Arc<Mutex<Vec<Arc<dyn AsyncEngineContext>>>>,
}

impl HttpRequestContext {
    /// Create a new HTTP request context
    pub fn new() -> Self {
        Self {
            id: Uuid::new_v4().to_string(),
            cancel_token: CancellationToken::new(),
            created_at: Instant::now(),
            stopped: Arc::new(std::sync::atomic::AtomicBool::new(false)),
            child_context: Arc::new(Mutex::new(Vec::new())),
        }
    }

    /// Create a new context with a specific ID
    pub fn with_id(id: String) -> Self {
        Self {
            id,
            cancel_token: CancellationToken::new(),
            created_at: Instant::now(),
            stopped: Arc::new(std::sync::atomic::AtomicBool::new(false)),
            child_context: Arc::new(Mutex::new(Vec::new())),
        }
    }

    /// Create a child context from this parent context
    /// The child will be cancelled when the parent is cancelled
    pub fn child(&self) -> Self {
        Self {
            id: Uuid::new_v4().to_string(),
            cancel_token: self.cancel_token.child_token(),
            created_at: Instant::now(),
            stopped: Arc::new(std::sync::atomic::AtomicBool::new(false)),
            child_context: Arc::new(Mutex::new(Vec::new())),
        }
    }

    /// Create a child context with a specific ID
    pub fn child_with_id(&self, id: String) -> Self {
        Self {
            id,
            cancel_token: self.cancel_token.child_token(),
            created_at: Instant::now(),
            stopped: Arc::new(std::sync::atomic::AtomicBool::new(false)),
            child_context: Arc::new(Mutex::new(Vec::new())),
        }
    }

    /// Get the cancellation token for use with reqwest
    pub fn cancellation_token(&self) -> CancellationToken {
        self.cancel_token.clone()
    }

    /// Get the elapsed time since context creation
    pub fn elapsed(&self) -> std::time::Duration {
        self.created_at.elapsed()
    }
}

impl Default for HttpRequestContext {
    fn default() -> Self {
        Self::new()
    }
}

impl std::fmt::Debug for HttpRequestContext {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("HttpRequestContext")
            .field("id", &self.id)
            .field("created_at", &self.created_at)
            .field("is_stopped", &self.is_stopped())
            .field("is_killed", &self.is_killed())
            .field("is_cancelled", &self.cancel_token.is_cancelled())
            .finish()
    }
}

#[async_trait]
impl AsyncEngineContext for HttpRequestContext {
    fn id(&self) -> &str {
        &self.id
    }

    fn stop(&self) {
        // Clone child Arcs to avoid deadlock if parent is accidentally linked under child
        let children = self
            .child_context
            .lock()
            .expect("Failed to lock child context")
            .iter()
            .cloned()
            .collect::<Vec<_>>();
        for child in children {
            child.stop();
        }

        self.stopped
            .store(true, std::sync::atomic::Ordering::Release);
        self.cancel_token.cancel();
    }

    fn stop_generating(&self) {
        // Clone child Arcs to avoid deadlock if parent is accidentally linked under child
        let children = self
            .child_context
            .lock()
            .expect("Failed to lock child context")
            .iter()
            .cloned()
            .collect::<Vec<_>>();
        for child in children {
            child.stop_generating();
        }

        // For HTTP clients, stop_generating is the same as stop
        self.stopped
            .store(true, std::sync::atomic::Ordering::Release);
        self.cancel_token.cancel();
    }

    fn kill(&self) {
        // Clone child Arcs to avoid deadlock if parent is accidentally linked under child
        let children = self
            .child_context
            .lock()
            .expect("Failed to lock child context")
            .iter()
            .cloned()
            .collect::<Vec<_>>();
        for child in children {
            child.kill();
        }

        self.stopped
            .store(true, std::sync::atomic::Ordering::Release);
        self.cancel_token.cancel();
    }

    fn is_stopped(&self) -> bool {
        self.stopped.load(std::sync::atomic::Ordering::Acquire)
    }

    fn is_killed(&self) -> bool {
        self.stopped.load(std::sync::atomic::Ordering::Acquire)
    }

    async fn stopped(&self) {
        self.cancel_token.cancelled().await;
    }

    async fn killed(&self) {
        // For HTTP clients, killed is the same as stopped
        self.cancel_token.cancelled().await;
    }

    fn link_child(&self, child: Arc<dyn AsyncEngineContext>) {
        self.child_context
            .lock()
            .expect("Failed to lock child context")
            .push(child);
    }
}

/// Base HTTP client with common functionality
pub struct BaseHttpClient {
    /// async-openai client
    client: Client<OpenAIConfig>,
    /// Client configuration
    config: HttpClientConfig,
    /// Root context for this client
    root_context: HttpRequestContext,
}

impl BaseHttpClient {
    /// Create a new base HTTP client
    pub fn new(config: HttpClientConfig) -> Self {
        let client = Client::with_config(config.openai_config.clone());
        Self {
            client,
            config,
            root_context: HttpRequestContext::new(),
        }
    }

    /// Get a reference to the underlying async-openai client
    pub fn client(&self) -> &Client<OpenAIConfig> {
        &self.client
    }

    /// Create a new request context as a child of the root context
    pub fn create_context(&self) -> HttpRequestContext {
        self.root_context.child()
    }

    /// Create a new request context with a specific ID as a child of the root context
    pub fn create_context_with_id(&self, id: String) -> HttpRequestContext {
        self.root_context.child_with_id(id)
    }

    /// Get the root context for this client
    pub fn root_context(&self) -> &HttpRequestContext {
        &self.root_context
    }

    /// Check if verbose logging is enabled
    pub fn is_verbose(&self) -> bool {
        self.config.verbose
    }
}

/// Type alias for NV chat response stream
pub type NvChatResponseStream =
    DataStream<Result<Annotated<NvCreateChatCompletionStreamResponse>, OpenAIError>>;

/// Type alias for generic BYOT response stream
pub type ByotResponseStream = DataStream<Result<Value, OpenAIError>>;

/// Type alias for pure OpenAI chat response stream
pub type OpenAIChatResponseStream =
    DataStream<Result<dynamo_async_openai::types::CreateChatCompletionStreamResponse, OpenAIError>>;

/// A wrapped HTTP response stream that combines a stream with its context
/// This provides a unified interface for HTTP client responses
#[derive(Dissolve)]
pub struct HttpResponseStream<T> {
    /// The underlying stream of responses
    pub stream: DataStream<T>,
    /// The context for this request
    pub context: Arc<dyn AsyncEngineContext>,
}

impl<T> HttpResponseStream<T> {
    /// Create a new HttpResponseStream
    pub fn new(stream: DataStream<T>, context: Arc<dyn AsyncEngineContext>) -> Self {
        Self { stream, context }
    }
}

impl<T: Data> Stream for HttpResponseStream<T> {
    type Item = T;

    fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
        Pin::new(&mut self.stream).poll_next(cx)
    }
}

impl<T: Data> AsyncEngineContextProvider for HttpResponseStream<T> {
    fn context(&self) -> Arc<dyn AsyncEngineContext> {
        self.context.clone()
    }
}

impl<T: Data> HttpResponseStream<T> {
    /// Convert this HttpResponseStream to a Pin<Box<dyn AsyncEngineStream<T>>>
    /// This requires the stream to be Send + Sync, which may not be true for all streams
    pub fn into_async_engine_stream(self) -> Pin<Box<dyn AsyncEngineStream<T>>>
    where
        T: 'static,
    {
        // This will only work if the underlying stream is actually Send + Sync
        // For now, we create a wrapper that assumes this
        Box::pin(AsyncEngineStreamWrapper {
            stream: self.stream,
            context: self.context,
        })
    }
}

/// A wrapper that implements AsyncEngineStream for streams that are Send + Sync
struct AsyncEngineStreamWrapper<T> {
    stream: DataStream<T>,
    context: Arc<dyn AsyncEngineContext>,
}

impl<T: Data> Stream for AsyncEngineStreamWrapper<T> {
    type Item = T;

    fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
        Pin::new(&mut self.stream).poll_next(cx)
    }
}

impl<T: Data> AsyncEngineContextProvider for AsyncEngineStreamWrapper<T> {
    fn context(&self) -> Arc<dyn AsyncEngineContext> {
        self.context.clone()
    }
}

impl<T: Data> AsyncEngineStream<T> for AsyncEngineStreamWrapper<T> {}

impl<T> std::fmt::Debug for AsyncEngineStreamWrapper<T> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("AsyncEngineStreamWrapper")
            .field("context", &self.context)
            .finish()
    }
}

impl<T: Data> std::fmt::Debug for HttpResponseStream<T> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("HttpResponseStream")
            .field("context", &self.context)
            .finish()
    }
}

/// Type alias for HttpResponseStream with NV chat completion responses
pub type NvHttpResponseStream =
    HttpResponseStream<Result<Annotated<NvCreateChatCompletionStreamResponse>, OpenAIError>>;

/// Type alias for HttpResponseStream with BYOT responses
pub type ByotHttpResponseStream = HttpResponseStream<Result<Value, OpenAIError>>;

/// Type alias for HttpResponseStream with pure OpenAI responses
pub type OpenAIHttpResponseStream = HttpResponseStream<
    Result<dynamo_async_openai::types::CreateChatCompletionStreamResponse, OpenAIError>,
>;

/// Pure OpenAI client using standard async-openai types
pub struct PureOpenAIClient {
    base: BaseHttpClient,
}

impl PureOpenAIClient {
    /// Create a new pure OpenAI client
    pub fn new(config: HttpClientConfig) -> Self {
        Self {
            base: BaseHttpClient::new(config),
        }
    }

    /// Create streaming chat completions using standard OpenAI types
    /// Uses a client-managed context
    pub async fn chat_stream(
        &self,
        request: dynamo_async_openai::types::CreateChatCompletionRequest,
    ) -> Result<OpenAIHttpResponseStream, HttpClientError> {
        let ctx = self.base.create_context();
        self.chat_stream_with_context(request, ctx).await
    }

    /// Create streaming chat completions with a custom context
    pub async fn chat_stream_with_context(
        &self,
        request: dynamo_async_openai::types::CreateChatCompletionRequest,
        context: HttpRequestContext,
    ) -> Result<OpenAIHttpResponseStream, HttpClientError> {
        let ctx_arc: Arc<dyn AsyncEngineContext> = Arc::new(context.clone());

        if !request.stream.unwrap_or(false) {
            return Err(HttpClientError::InvalidRequest(
                "chat_stream requires the request to have 'stream': true".to_string(),
            ));
        }

        if self.base.is_verbose() {
            tracing::info!(
                "Starting pure OpenAI chat stream for request {}",
                context.id()
            );
        }

        // Create the stream with cancellation support
        let stream = self
            .base
            .client()
            .chat()
            .create_stream(request)
            .await
            .map_err(HttpClientError::OpenAI)?;

        // TODO: In Phase 3, we'll add cancellation integration with reqwest
        // For now, return the stream as-is
        Ok(HttpResponseStream::new(stream, ctx_arc))
    }
}

/// NV Custom client using NvCreateChatCompletionRequest with Annotated responses
pub struct NvCustomClient {
    base: BaseHttpClient,
}

impl NvCustomClient {
    /// Create a new NV custom client
    pub fn new(config: HttpClientConfig) -> Self {
        Self {
            base: BaseHttpClient::new(config),
        }
    }

    /// Create streaming chat completions using NV custom types
    /// Uses a client-managed context
    pub async fn chat_stream(
        &self,
        request: NvCreateChatCompletionRequest,
    ) -> Result<NvHttpResponseStream, HttpClientError> {
        let ctx = self.base.create_context();
        self.chat_stream_with_context(request, ctx).await
    }

    /// Create streaming chat completions with a custom context
    pub async fn chat_stream_with_context(
        &self,
        request: NvCreateChatCompletionRequest,
        context: HttpRequestContext,
    ) -> Result<NvHttpResponseStream, HttpClientError> {
        let ctx_arc: Arc<dyn AsyncEngineContext> = Arc::new(context.clone());

        if !request.inner.stream.unwrap_or(false) {
            return Err(HttpClientError::InvalidRequest(
                "chat_stream requires the request to have 'stream': true".to_string(),
            ));
        }

        if self.base.is_verbose() {
            tracing::info!(
                "Starting NV custom chat stream for request {}",
                context.id()
            );
        }

        // Use BYOT feature to send NvCreateChatCompletionRequest
        // The stream type is explicitly specified to deserialize directly into Annotated<NvCreateChatCompletionStreamResponse>
        let stream = self
            .base
            .client()
            .chat()
            .create_stream_byot(request)
            .await
            .map_err(HttpClientError::OpenAI)?;

        Ok(HttpResponseStream::new(stream, ctx_arc))
    }
}

/// Generic BYOT client using serde_json::Value for maximum flexibility
pub struct GenericBYOTClient {
    base: BaseHttpClient,
}

impl GenericBYOTClient {
    /// Create a new generic BYOT client
    pub fn new(config: HttpClientConfig) -> Self {
        Self {
            base: BaseHttpClient::new(config),
        }
    }

    /// Create streaming chat completions using arbitrary JSON values
    /// Uses a client-managed context
    pub async fn chat_stream(
        &self,
        request: Value,
    ) -> Result<ByotHttpResponseStream, HttpClientError> {
        let ctx = self.base.create_context();
        self.chat_stream_with_context(request, ctx).await
    }

    /// Create streaming chat completions with a custom context
    pub async fn chat_stream_with_context(
        &self,
        request: Value,
        context: HttpRequestContext,
    ) -> Result<ByotHttpResponseStream, HttpClientError> {
        let ctx_arc: Arc<dyn AsyncEngineContext> = Arc::new(context.clone());

        if self.base.is_verbose() {
            tracing::info!(
                "Starting generic BYOT chat stream for request {}",
                context.id()
            );
        }

        // Validate that the request has stream: true
        if let Some(stream_val) = request.get("stream") {
            if !stream_val.as_bool().unwrap_or(false) {
                return Err(HttpClientError::InvalidRequest(
                    "Request must have 'stream': true for streaming".to_string(),
                ));
            }
        } else {
            return Err(HttpClientError::InvalidRequest(
                "Request must include 'stream' field".to_string(),
            ));
        }

        // Use BYOT feature with raw JSON
        // The stream type is explicitly specified to deserialize directly into serde_json::Value
        let stream = self
            .base
            .client()
            .chat()
            .create_stream_byot(request)
            .await
            .map_err(HttpClientError::OpenAI)?;

        Ok(HttpResponseStream::new(stream, ctx_arc))
    }
}

// TODO: Implement recording integration in Phase 3:
// - Recording wrapper functions
// - Capacity hints from request parameters
// - Integration with existing recording infrastructure

#[cfg(test)]
mod tests {
    use super::*;
    use tokio::time::{Duration, sleep};

    #[tokio::test]
    async fn test_http_request_context_creation() {
        let ctx = HttpRequestContext::new();
        assert!(!ctx.id().is_empty());
        assert!(!ctx.is_stopped());
        assert!(!ctx.is_killed());
    }

    #[tokio::test]
    async fn test_http_request_context_child() {
        let parent = HttpRequestContext::new();
        let child = parent.child();

        // Child should have different ID
        assert_ne!(parent.id(), child.id());

        // Child should not be stopped initially
        assert!(!child.is_stopped());

        // When parent is stopped, child should be cancelled via token
        parent.stop();
        assert!(parent.is_stopped());
        assert!(child.cancellation_token().is_cancelled());
    }

    #[tokio::test]
    async fn test_http_request_context_child_with_id() {
        let parent = HttpRequestContext::new();
        let child_id = "test-child";
        let child = parent.child_with_id(child_id.to_string());

        assert_eq!(child.id(), child_id);
        assert!(!child.is_stopped());

        // Test hierarchical cancellation
        parent.stop();
        assert!(child.cancellation_token().is_cancelled());
    }

    #[tokio::test]
    async fn test_http_request_context_cancellation() {
        let ctx = HttpRequestContext::new();
        let cancel_token = ctx.cancellation_token();

        // Test stop functionality
        assert!(!ctx.is_stopped());
        ctx.stop();
        assert!(ctx.is_stopped());
        assert!(cancel_token.is_cancelled());
    }

    #[tokio::test]
    async fn test_http_request_context_kill() {
        let ctx = HttpRequestContext::new();

        // Test kill functionality
        assert!(!ctx.is_killed());
        ctx.kill();
        assert!(ctx.is_killed());
        assert!(ctx.is_stopped());
    }

    #[tokio::test]
    async fn test_http_request_context_async_cancellation() {
        let ctx = HttpRequestContext::new();

        // Test async cancellation
        let ctx_clone = ctx.clone();
        let task = tokio::spawn(async move {
            ctx_clone.stopped().await;
        });

        // Give a moment for the task to start waiting
        sleep(Duration::from_millis(10)).await;

        // Cancel the context
        ctx.stop();

        // The task should complete
        task.await.unwrap();
    }

    #[test]
    fn test_base_http_client_creation() {
        let config = HttpClientConfig::default();
        let client = BaseHttpClient::new(config);
        assert!(!client.is_verbose());

        // Test that client has a root context
        assert!(!client.root_context().id().is_empty());
    }

    #[test]
    fn test_base_http_client_context_creation() {
        let config = HttpClientConfig::default();
        let client = BaseHttpClient::new(config);

        // Test creating child contexts
        let ctx1 = client.create_context();
        let ctx2 = client.create_context();

        // Should have different IDs
        assert_ne!(ctx1.id(), ctx2.id());

        // Should be children of root context
        client.root_context().stop();
        assert!(ctx1.cancellation_token().is_cancelled());
        assert!(ctx2.cancellation_token().is_cancelled());
    }

    #[test]
    fn test_base_http_client_context_with_id() {
        let config = HttpClientConfig::default();
        let client = BaseHttpClient::new(config);

        let custom_id = "custom-request-id";
        let ctx = client.create_context_with_id(custom_id.to_string());

        assert_eq!(ctx.id(), custom_id);

        // Should still be child of root
        client.root_context().stop();
        assert!(ctx.cancellation_token().is_cancelled());
    }

    #[test]
    fn test_http_client_config_defaults() {
        let config = HttpClientConfig::default();
        assert!(!config.verbose);
    }

    #[test]
    fn test_pure_openai_client_creation() {
        let config = HttpClientConfig::default();
        let _client = PureOpenAIClient::new(config);
        // If we get here, creation succeeded
    }

    #[test]
    fn test_nv_custom_client_creation() {
        let config = HttpClientConfig::default();
        let _client = NvCustomClient::new(config);
        // If we get here, creation succeeded
    }

    #[test]
    fn test_generic_byot_client_creation() {
        let config = HttpClientConfig::default();
        let _client = GenericBYOTClient::new(config);
        // If we get here, creation succeeded
    }
}