pub struct ChatCompletionRequestSystemMessage {
pub content: ChatCompletionRequestSystemMessageContent,
pub name: Option<String>,
pub tools: Option<Vec<Value>>,
}Expand description
System message with dynamic tool metadata support.
Extends upstream ChatCompletionRequestSystemMessage with:
content: still required in the public Rust type. On the wire only, Kimi-style messages may omit it (or sendnull) when they declare non-emptytools; deserialization canonicalizes that shape to empty text. Every other content-less system message is still rejected with upstream’smissing field \content`error, so spec-conformant clients and non-Kimi models see no behavior change. Without this guard a bare{“role”: “system”}` would reach ordinary HF jinja templates and render an empty system turn instead of failing the request.tools: passthrough field for model-specific tool metadata rendered by the chat template. Dynamo does not interpret this field; it is preserved verbatim for downstream chat-template rendering.
Default (and therefore the builder’s unset state) uses empty-string
content, matching upstream. Keeping content non-optional also prevents
programmatic callers from constructing a content-less, tool-less message.
Fields§
§content: ChatCompletionRequestSystemMessageContent§name: Option<String>§tools: Option<Vec<Value>>Kimi-style dynamic tool metadata carried on a system message.
Moonshot treats omitted, null, and empty content as no system text;
renderers enforce that non-empty content and tools are mutually
exclusive and that tools is non-empty. The list shape is typed here
so non-array values are rejected at deserialization.
Entries stay raw JSON rather than a typed schema on purpose: this crate
only needs to preserve them for downstream chat-template rendering,
which reads them back as generic JSON by key. A typed entry (e.g.
FunctionObject) would silently drop vendor-specific keys serde doesn’t
know about on round-trip, whereas serde_json::Value is structurally
lossless (JSON structure and unknown keys survive; whitespace, number
spelling, and duplicate keys do not).
Kimi’s encoding_k3.py renders this through the same tool-declare path
as the top-level tools field and never inspects individual entries, so
the canonical shape is the same OpenAI wrapped form,
{"type": "function", "function": {...}}. Clients that send bare
function-schema objects ({"name": ..., "parameters": ...}) are passed
through unchanged as well; this crate takes no position on the shape.
Trait Implementations§
Source§impl Clone for ChatCompletionRequestSystemMessage
impl Clone for ChatCompletionRequestSystemMessage
Source§fn clone(&self) -> ChatCompletionRequestSystemMessage
fn clone(&self) -> ChatCompletionRequestSystemMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more