Skip to main content

ChatRequest

Struct ChatRequest 

Source
pub struct ChatRequest {
Show 15 fields pub model: String, pub messages: Vec<Message>, pub audio: Option<Audio>, pub frequency_penalty: Option<f32>, pub max_completion_tokens: Option<u32>, pub presence_penalty: Option<f32>, pub response_format: Option<ResponseFormat>, pub stop: Option<Stop>, pub stream: Option<bool>, pub thinking: Option<Thinking>, pub temperature: Option<f32>, pub tool_choice: Option<ToolChoice>, pub tools: Option<Vec<Tool>>, pub top_p: Option<f32>, pub web_search_enabled: Option<bool>,
}
Expand description

Chat completion request.

Fields§

§model: String

The model to use for generation

§messages: Vec<Message>

List of messages in the conversation

§audio: Option<Audio>

Audio output parameters (for TTS)

§frequency_penalty: Option<f32>

Frequency penalty (-2.0 to 2.0)

§max_completion_tokens: Option<u32>

Maximum completion tokens

§presence_penalty: Option<f32>

Presence penalty (-2.0 to 2.0)

§response_format: Option<ResponseFormat>

Response format

§stop: Option<Stop>

Stop sequences

§stream: Option<bool>

Enable streaming response

§thinking: Option<Thinking>

Thinking mode configuration

§temperature: Option<f32>

Sampling temperature (0 to 1.5)

§tool_choice: Option<ToolChoice>

Tool choice

§tools: Option<Vec<Tool>>

List of tools

§top_p: Option<f32>

Top-p sampling (0.01 to 1.0)

§web_search_enabled: Option<bool>

Enable web search capability.

Note: You must first enable the “联网服务插件” (Web Search Plugin) in the MiMo console before using this feature. If the plugin is not enabled, setting this to true will result in a 400 error.

Implementations§

Source§

impl ChatRequest

Source

pub fn new(model: impl Into<String>) -> Self

Create a new chat request with the specified model.

Source

pub fn flash() -> Self

Create a chat request with the MiMo V2 Flash model.

Source

pub fn pro() -> Self

Create a chat request with the MiMo V2 Pro model.

Source

pub fn v25_pro() -> Self

Create a chat request with the MiMo V2.5 Pro model.

Source

pub fn v25() -> Self

Create a chat request with the MiMo V2.5 model.

Source

pub fn omni() -> Self

Create a chat request with the MiMo V2 Omni model.

Source

pub fn v25_tts() -> Self

Create a chat request with the MiMo V2.5 TTS model (preset voices).

Source

pub fn v25_tts_voicedesign() -> Self

Create a chat request with the MiMo V2.5 TTS VoiceDesign model.

Source

pub fn v25_tts_voiceclone() -> Self

Create a chat request with the MiMo V2.5 TTS VoiceClone model.

Source

pub fn tts() -> Self

Create a chat request with the MiMo V2 TTS model (legacy).

Source

pub fn model(self, model: impl Into<String>) -> Self

Set the model.

Source

pub fn message(self, message: Message) -> Self

Add a message to the conversation.

Source

pub fn messages(self, messages: Vec<Message>) -> Self

Add multiple messages to the conversation.

If a system message was previously set via [system()] and the new messages do not already contain a system message, the existing system message is preserved and placed at the beginning.

Source

pub fn system(self, content: impl Into<String>) -> Self

Add a system message.

The system message is always placed at the beginning of the message list (index 0), regardless of whether this method is called before or after other messages are added.

Source

pub fn user(self, content: impl Into<String>) -> Self

Add a user message.

Source

pub fn assistant(self, content: impl Into<String>) -> Self

Add an assistant message.

Source

pub fn audio(self, audio: Audio) -> Self

Set audio output parameters (for TTS).

Source

pub fn frequency_penalty(self, penalty: f32) -> Self

Set the frequency penalty.

Source

pub fn max_completion_tokens(self, tokens: u32) -> Self

Set the maximum completion tokens.

Source

pub fn presence_penalty(self, penalty: f32) -> Self

Set the presence penalty.

Source

pub fn response_format(self, format: ResponseFormat) -> Self

Set the response format.

Source

pub fn stop(self, stop: Stop) -> Self

Set the stop sequences.

Source

pub fn stream(self, stream: bool) -> Self

Enable or disable streaming.

Source

pub fn thinking(self, thinking: Thinking) -> Self

Set the thinking mode.

Source

pub fn enable_thinking(self) -> Self

Enable thinking mode.

Source

pub fn disable_thinking(self) -> Self

Disable thinking mode.

Source

pub fn temperature(self, temperature: f32) -> Self

Set the temperature.

Source

pub fn tool_choice(self, choice: ToolChoice) -> Self

Set the tool choice.

Source

pub fn tool(self, tool: Tool) -> Self

Add a tool.

Source

pub fn tools(self, tools: Vec<Tool>) -> Self

Set the tools.

Source

pub fn top_p(self, top_p: f32) -> Self

Set the top-p.

Source

pub fn web_search_enabled(self, enabled: bool) -> Self

Enable or disable web search.

Note: You must first enable the “联网服务插件” (Web Search Plugin) in the MiMo console before using this feature. If the plugin is not enabled, setting this to true will result in a 400 error.

Trait Implementations§

Source§

impl Clone for ChatRequest

Source§

fn clone(&self) -> ChatRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChatRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChatRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ChatRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ChatRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,