pub enum Segment {
Text {
text: String,
extensions: SegmentExtensions,
},
Thinking {
text: String,
extensions: SegmentExtensions,
},
ToolCall {
call: ToolCall,
extensions: SegmentExtensions,
},
}Expand description
One ordered, producer-valid assistant-content segment.
The enum excludes text/thinking segments with calls and call segments without calls. Public variants are the complete construction and observation API.
use reef_core::opaque;
use reef_core::value::{content, tool_call};
let extensions = || content::SegmentExtensions::new(String::new(), None, Some(vec![]));
let segments = [
content::Segment::Text { text: "answer".into(), extensions: extensions() },
content::Segment::Thinking { text: "reason".into(), extensions: extensions() },
content::Segment::ToolCall {
call: tool_call::ToolCall::new(tool_call::Id::new("id".into()), tool_call::Name::new("tool".into()), opaque::Payload::from_vec(vec![])),
extensions: extensions(),
},
];
assert!(matches!(&segments[0], content::Segment::Text { text, extensions } if text == "answer" && extensions.provider_data().is_some_and(<[_]>::is_empty)));
assert!(matches!(&segments[1], content::Segment::Thinking { text, .. } if text == "reason"));
assert!(matches!(&segments[2], content::Segment::ToolCall { call, .. } if call.id().as_str() == "id"));Variants§
Text
Model-visible answer text.
Fields
extensions: SegmentExtensionsOpaque provider extensions attached to this segment.
Thinking
Reasoning or thinking content.
Fields
extensions: SegmentExtensionsOpaque provider extensions attached to this segment.
ToolCall
A model-initiated tool invocation.
Fields
extensions: SegmentExtensionsOpaque provider extensions attached to this segment.
Trait Implementations§
Source§impl Debug for Segment
impl Debug for Segment
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
Keeps the variant and sizes the text, in both content lanes alike.
Reasoning is not a stricter tier than answer text. Tier 2 already emits
zero content bytes, so “stricter” could only mean “emit nothing” — and a
provider is free to deliver reasoning inside Segment::Text anyway, so
a thinking-only rule would be a guarantee the data can walk around. What
a compliance-minded operator needs survives: the discriminant states
that the model reasoned and the size states how much.