mcprotocol_rs/client_features/
sampling.rs1use async_trait::async_trait;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5use crate::Result;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct SamplingRequest {
10 pub prompt: Value,
12 pub parameters: Option<Value>,
14 pub stop: Option<Vec<String>>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct SamplingResponse {
21 pub text: String,
23 pub metadata: Option<Value>,
25}
26
27#[async_trait]
29pub trait SamplingHandler: Send + Sync {
30 async fn handle_request(&self, request: SamplingRequest) -> Result<SamplingResponse>;
32
33 async fn cancel(&self) -> Result<()>;
35}