Context Segment • Rust AI Agent SDK

ContextSegment: A segment of context with token count.

ContextSegment

Defined in the context module.

Rust AI Agent SDK

A segment of context with token count.

Fields

NameTypeDescription
nameStringSegment name/type
tokensusizeToken count for this segment
priorityi32Priority (higher = more important)
contentOption<String>Content of the segment

Methods

new

rust
fn new(name: impl Into<String>, tokens: usize) -> Self

Create a new context segment

Parameters:

NameType
nameimpl Into&lt;String&gt;
tokensusize

priority

rust
fn priority(mut self, priority: i32) -> Self

Set priority

Parameters:

NameType
priorityi32

content

rust
fn content(mut self, content: impl Into<String>) -> Self

Set content

Parameters:

NameType
contentimpl Into&lt;String&gt;

Source

View on GitHub

praisonai/src/context/mod.rs at line 54


Related Documentation