pub struct RunState { /* private fields */ }Expand description
Request-scoped values a run is given when it starts: a user id, a tenant,
a database handle. Nodes, edge_if conditions
and node_fn_with_state functions read them
through GraphState::run_state or NodeIo::run_state.
Values are typed: one value per type, read back by type. They are never
sent to a model: an agent node gets only its input text, and the tools of
an agent cannot read them (Rig gives a tool only the serializable
ToolContext). They are not saved in checkpoints either, so a run resumed
with run_as_with_state or
stream_as_with_state must be given the
state again.
use rig_multiagent::RunState;
struct TenantId(String);
let state = RunState::new().with(TenantId("acme".to_owned()));
assert_eq!(state.get::<TenantId>().map(|tenant| tenant.0.as_str()), Some("acme"));Implementations§
Trait Implementations§
impl RefUnwindSafe for RunState
impl UnwindSafe for RunState
Auto Trait Implementations§
impl Forget for RunState
impl Freeze for RunState
impl Move for RunState
impl Send for RunState
impl Sync for RunState
impl Unpin for RunState
impl UnsafeUnpin for RunState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more