Skip to main content

Turn

Struct Turn 

Source
pub struct Turn {
    pub role: String,
    pub content: String,
    pub tool_calls: Vec<ToolCall>,
    pub reasoning: Option<String>,
    pub tool_call_id: Option<String>,
    pub tool_name: Option<String>,
    pub tool_responses: Vec<(String, Val)>,
    pub task: Option<String>,
    pub tools: Vec<Val>,
}
Expand description

One chat turn for the tools-capable renderer (apply_chat_template_tools). The reasoning/tool_call_id/tool_name/tool_responses fields are read ONLY by the gemma4 arm; the qwen/step arms use role/content/tool_calls and leave the rest default.

Fields§

§role: String§content: String§tool_calls: Vec<ToolCall>§reasoning: Option<String>

gemma4: assistant reasoning re-rendered as a <|channel>thought span (only for a tool_calls-carrying assistant after the last user message — the template’s guard).

§tool_call_id: Option<String>

gemma4: on a role:“tool” turn, the OpenAI tool_call_id used to resolve the response name against the preceding assistant’s tool_calls[].id.

§tool_name: Option<String>

gemma4: on a role:“tool” turn, the message’s own name field (fallback when the id does not resolve).

§tool_responses: Vec<(String, Val)>

gemma4 native (Google) responses embedded on an assistant turn: (name, response value). OpenAI histories leave this empty and use role:“tool” turns instead.

§task: Option<String>

deepseek-v4 quick-instruction task token (action/query/authority/domain/ title/read_url, encoding_dsv4 DS_TASK_SP_TOKENS). Set only by the dsv4 fixture harness (the internal-classification heads); the OpenAI serve surface has no task field, so every serve request leaves this None and every other dialect ignores it.

§tools: Vec<Val>

deepseek-v4 per-turn tool function objects (encoding_dsv4 renders the tool declaration on the message carrying them — system on the serve surface, or a developer message in the search-pipeline fixtures). The serve path also passes request-level tools via tools_struct, which the dsv4 arm folds onto the leading system turn. Every other dialect ignores this.

Trait Implementations§

Source§

impl Clone for Turn

Source§

fn clone(&self) -> Turn

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 Turn

Source§

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

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

impl Default for Turn

Source§

fn default() -> Turn

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

impl PartialEq for Turn

Source§

fn eq(&self, other: &Turn) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Turn

Auto Trait Implementations§

§

impl Freeze for Turn

§

impl RefUnwindSafe for Turn

§

impl Send for Turn

§

impl Sync for Turn

§

impl Unpin for Turn

§

impl UnsafeUnpin for Turn

§

impl UnwindSafe for Turn

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.