pub struct SamplingLlmClient { /* private fields */ }Expand description
LlmClient impl whose complete() calls back via the connected
MCP client’s sampling capability.
Construct via SamplingLlmClient::new (production path: wraps a
real Peer<RoleServer>) or SamplingLlmClient::with_sampling_client
(test path: takes the abstracted SamplingClient trait object
directly so [super::super::test_support::fake_mcp_client:: FakeMcpClient] can drive it).
Cheap to clone — every field is Arc-shared.
Implementations§
Source§impl SamplingLlmClient
impl SamplingLlmClient
Sourcepub fn new(
peer: Peer<RoleServer>,
write_handle: WriteHandle,
audit_principal: Option<String>,
) -> Self
pub fn new( peer: Peer<RoleServer>, write_handle: WriteHandle, audit_principal: Option<String>, ) -> Self
Build a client wrapping a real Peer<RoleServer>. Production
path — called from
crate::mcp::SoloMcpServer::populate_sampling_steward when an MCP
session reaches initialize with a sampling-capable peer.
Sourcepub fn with_sampling_client(
sampling_client: Arc<dyn SamplingClient>,
write_handle: WriteHandle,
audit_principal: Option<String>,
) -> Self
pub fn with_sampling_client( sampling_client: Arc<dyn SamplingClient>, write_handle: WriteHandle, audit_principal: Option<String>, ) -> Self
Test-friendly constructor accepting any SamplingClient
implementation. Pair with
[super::super::test_support::fake_mcp_client::FakeMcpClient]
in tests.
Sourcepub fn with_max_tokens(self, n: u32) -> Self
pub fn with_max_tokens(self, n: u32) -> Self
Override the per-call max_tokens cap.
Sourcepub fn with_timeout(self, t: Duration) -> Self
pub fn with_timeout(self, t: Duration) -> Self
Override the per-call timeout.
Trait Implementations§
Source§impl Clone for SamplingLlmClient
impl Clone for SamplingLlmClient
Source§fn clone(&self) -> SamplingLlmClient
fn clone(&self) -> SamplingLlmClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl LlmClient for SamplingLlmClient
impl LlmClient for SamplingLlmClient
Source§fn name(&self) -> &str
fn name(&self) -> &str
Provenance::by).Source§fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = CoreResult<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = CoreResult<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn is_real_llm(&self) -> bool
fn is_real_llm(&self) -> bool
complete() returns canned data. Read moreAuto Trait Implementations§
impl Freeze for SamplingLlmClient
impl !RefUnwindSafe for SamplingLlmClient
impl Send for SamplingLlmClient
impl Sync for SamplingLlmClient
impl Unpin for SamplingLlmClient
impl UnsafeUnpin for SamplingLlmClient
impl !UnwindSafe for SamplingLlmClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more