Skip to main content

Config

Struct Config 

Source
pub struct Config<M: Client> { /* private fields */ }
Expand description

Mutable owned assembly consumed into one immutable Agent revision.

Everything an Agent will hold is gathered here and then frozen: the model client, the tools, the hooks, and the default request material every Step starts from. Agent::new consumes it.

use reef_core::runtime::{agent, hook, tool};
use reef_core::value::content;

let tools = tool::RegistryBuilder::new().build().unwrap();
let hooks = hook::RegistryBuilder::new();

let mut config = agent::Config::new(Arc::new(Offline), tools, hooks);
config.push_system_instruction(content::Part::text("Be terse.".to_owned()));
config.sampling_mut().temperature = Some(0.2);

assert_eq!(config.system_instruction().len(), 1);
let agent = agent::Agent::new(config).unwrap();

Implementations§

Source§

impl<M: Client> Config<M>

Source

pub fn new(model: Arc<M>, tools: Registry, hooks: RegistryBuilder) -> Self

Creates a configuration with empty, provider-neutral defaults.

§Why the two registries arrive in different states

tools is a built tool::Registry and hooks is still a hook::RegistryBuilder. A tool registry is an immutable value: it is Clone, it holds no authority, and several agents may share one. The hook builder is instead consumed here so Agent::new can build exactly one Agent-private runtime registry from it. Nothing reachable from Config, Agent, Revision, or a Run hands that registry back, which makes Agent::close its only teardown route.

Source

pub fn system_instruction(&self) -> &[Part]

Returns the ordered default system instruction.

Source

pub fn push_system_instruction(&mut self, part: Part) -> &mut Self

Appends one block to the default system instruction.

Source

pub fn extend_system_instruction( &mut self, parts: impl IntoIterator<Item = Part>, ) -> &mut Self

Appends blocks to the default system instruction in iteration order.

Source

pub fn clear_system_instruction(&mut self) -> &mut Self

Removes every default system-instruction block.

Source

pub const fn sampling_mut(&mut self) -> &mut SamplingParams

Returns the default sampling controls.

Source

pub fn model_extensions(&self) -> &[Envelope]

Returns the default provider-hosted extension lane.

Source

pub fn push_model_extension(&mut self, extension: Envelope) -> &mut Self

Appends one provider-hosted extension.

Source

pub fn extend_model_extensions( &mut self, extensions: impl IntoIterator<Item = Envelope>, ) -> &mut Self

Appends provider-hosted extensions in iteration order.

Source

pub fn clear_model_extensions(&mut self) -> &mut Self

Removes every provider-hosted extension.

Trait Implementations§

Source§

impl<M: Client> Debug for Config<M>

Source§

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

Shows everything a revision will freeze except the model itself.

M carries no Debug bound, because requiring one would make an Agent unprintable for every provider that has not opted in — a cost paid by users to describe the one field they already know, since they supplied it. The trailing .. says so rather than pretending the field is absent.

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for Config<M>

§

impl<M> !UnwindSafe for Config<M>

§

impl<M> Freeze for Config<M>
where Arc<M>: Freeze,

§

impl<M> Send for Config<M>
where Arc<M>: Send,

§

impl<M> Sync for Config<M>
where Arc<M>: Sync,

§

impl<M> Unpin for Config<M>
where Arc<M>: Unpin,

§

impl<M> UnsafeUnpin for Config<M>
where Arc<M>: UnsafeUnpin,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.