Skip to main content

SamplingProvider

Trait SamplingProvider 

Source
pub trait SamplingProvider: Send + Sync {
    // Required methods
    fn is_available(&self) -> bool;
    fn sample(
        &self,
        request: SamplingRequest,
    ) -> BoxFuture<'_, Result<SamplingResponse, SamplingError>>;
}
Expand description

Provides LLM sampling for tool-internal use.

Implementations include MCP sampling/createMessage delegation and direct model invocation.

The sample method returns a BoxFuture so that the trait remains object-safe and can be used as dyn SamplingProvider.

Required Methods§

Source

fn is_available(&self) -> bool

Returns true if sampling is available (provider configured).

Source

fn sample( &self, request: SamplingRequest, ) -> BoxFuture<'_, Result<SamplingResponse, SamplingError>>

Request a completion from the LLM.

Returns a boxed future to preserve object safety.

Implementors§