pub struct DirectModelSampling { /* private fields */ }Expand description
A sampling provider backed by direct model invocation.
Used when running the agent without an MCP host. Wraps a caller-supplied
callback that performs the actual model call. When no callback is provided
(via DirectModelSampling::unavailable), all sampling calls return
SamplingError::NotAvailable to trigger graceful degradation in callers.
Implementations§
Source§impl DirectModelSampling
impl DirectModelSampling
Sourcepub fn new(
invoke: impl Fn(SamplingRequest) -> BoxFuture<'static, Result<SamplingResponse, SamplingError>> + Send + Sync + 'static,
) -> Self
pub fn new( invoke: impl Fn(SamplingRequest) -> BoxFuture<'static, Result<SamplingResponse, SamplingError>> + Send + Sync + 'static, ) -> Self
Create a new provider with the given model invocation callback.
The callback is wrapped in an Arc so the provider remains Clone-friendly
and can be shared across tasks.
Create a provider that always reports sampling as unavailable.
SamplingProvider::is_available will return false and all calls to
SamplingProvider::sample will return SamplingError::NotAvailable.
Trait Implementations§
Source§impl SamplingProvider for DirectModelSampling
impl SamplingProvider for DirectModelSampling
Source§fn is_available(&self) -> bool
fn is_available(&self) -> bool
Returns
true if sampling is available (provider configured).Source§fn sample(
&self,
request: SamplingRequest,
) -> BoxFuture<'_, Result<SamplingResponse, SamplingError>>
fn sample( &self, request: SamplingRequest, ) -> BoxFuture<'_, Result<SamplingResponse, SamplingError>>
Request a completion from the LLM. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for DirectModelSampling
impl !UnwindSafe for DirectModelSampling
impl Freeze for DirectModelSampling
impl Send for DirectModelSampling
impl Sync for DirectModelSampling
impl Unpin for DirectModelSampling
impl UnsafeUnpin for DirectModelSampling
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
Mutably borrows from an owned value. Read more