#[non_exhaustive]pub struct CreateMessageRequestParams {
pub meta: Option<Meta>,
pub task: Option<JsonObject>,
pub messages: Vec<SamplingMessage>,
pub model_preferences: Option<ModelPreferences>,
pub system_prompt: Option<String>,
pub include_context: Option<ContextInclusion>,
pub temperature: Option<f32>,
pub max_tokens: u32,
pub stop_sequences: Option<Vec<String>>,
pub metadata: Option<Value>,
pub tools: Option<Vec<Tool>>,
pub tool_choice: Option<ToolChoice>,
}Expand description
Parameters for creating a message through LLM sampling.
This structure contains all the necessary information for a client to generate an LLM response, including conversation history, model preferences, and generation parameters.
This implements TaskAugmentedRequestParamsMeta as sampling requests can be
long-running and may benefit from task-based execution.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.meta: Option<Meta>Protocol-level metadata for this request (SEP-1319)
task: Option<JsonObject>Task metadata for async task management (SEP-1319)
messages: Vec<SamplingMessage>The conversation history and current messages
model_preferences: Option<ModelPreferences>Preferences for model selection and behavior
system_prompt: Option<String>System prompt to guide the model’s behavior
include_context: Option<ContextInclusion>How much context to include from MCP servers
temperature: Option<f32>Temperature for controlling randomness (0.0 to 1.0)
max_tokens: u32Maximum number of tokens to generate
stop_sequences: Option<Vec<String>>Sequences that should stop generation
metadata: Option<Value>Additional metadata for the request
tools: Option<Vec<Tool>>Tools available for the model to call (SEP-1577)
tool_choice: Option<ToolChoice>Tool selection behavior (SEP-1577)
Implementations§
Source§impl CreateMessageRequestParams
impl CreateMessageRequestParams
Sourcepub fn new(messages: Vec<SamplingMessage>, max_tokens: u32) -> Self
pub fn new(messages: Vec<SamplingMessage>, max_tokens: u32) -> Self
Create a new CreateMessageRequestParams with required fields.
Sourcepub fn with_model_preferences(self, model_preferences: ModelPreferences) -> Self
pub fn with_model_preferences(self, model_preferences: ModelPreferences) -> Self
Set model preferences.
Sourcepub fn with_system_prompt(self, system_prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, system_prompt: impl Into<String>) -> Self
Set system prompt.
Sourcepub fn with_include_context(self, include_context: ContextInclusion) -> Self
pub fn with_include_context(self, include_context: ContextInclusion) -> Self
Set include context.
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set temperature.
Sourcepub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> Self
pub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> Self
Set stop sequences.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Set metadata.
Sourcepub fn with_tools(self, tools: Vec<Tool>) -> Self
pub fn with_tools(self, tools: Vec<Tool>) -> Self
Set tools.
Sourcepub fn with_tool_choice(self, tool_choice: ToolChoice) -> Self
pub fn with_tool_choice(self, tool_choice: ToolChoice) -> Self
Set tool choice.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the sampling request parameters per SEP-1577 spec requirements.
Checks:
- ToolUse content is only allowed in assistant messages
- ToolResult content is only allowed in user messages
- Messages with tool result content MUST NOT contain other content types
- Every assistant ToolUse must be balanced with a corresponding user ToolResult
Trait Implementations§
Source§impl Clone for CreateMessageRequestParams
impl Clone for CreateMessageRequestParams
Source§fn clone(&self) -> CreateMessageRequestParams
fn clone(&self) -> CreateMessageRequestParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CreateMessageRequestParams
impl Debug for CreateMessageRequestParams
Source§impl Default for CreateMessageRequestParams
impl Default for CreateMessageRequestParams
Source§fn default() -> CreateMessageRequestParams
fn default() -> CreateMessageRequestParams
Source§impl<'de> Deserialize<'de> for CreateMessageRequestParams
impl<'de> Deserialize<'de> for CreateMessageRequestParams
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for CreateMessageRequestParams
impl JsonSchema for CreateMessageRequestParams
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more