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>
impl<M: Client> Config<M>
Sourcepub fn new(model: Arc<M>, tools: Registry, hooks: RegistryBuilder) -> Self
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.
Sourcepub fn system_instruction(&self) -> &[Part]
pub fn system_instruction(&self) -> &[Part]
Returns the ordered default system instruction.
Sourcepub fn push_system_instruction(&mut self, part: Part) -> &mut Self
pub fn push_system_instruction(&mut self, part: Part) -> &mut Self
Appends one block to the default system instruction.
Sourcepub fn extend_system_instruction(
&mut self,
parts: impl IntoIterator<Item = Part>,
) -> &mut Self
pub fn extend_system_instruction( &mut self, parts: impl IntoIterator<Item = Part>, ) -> &mut Self
Appends blocks to the default system instruction in iteration order.
Sourcepub fn clear_system_instruction(&mut self) -> &mut Self
pub fn clear_system_instruction(&mut self) -> &mut Self
Removes every default system-instruction block.
Sourcepub const fn sampling_mut(&mut self) -> &mut SamplingParams
pub const fn sampling_mut(&mut self) -> &mut SamplingParams
Returns the default sampling controls.
Sourcepub fn model_extensions(&self) -> &[Envelope]
pub fn model_extensions(&self) -> &[Envelope]
Returns the default provider-hosted extension lane.
Sourcepub fn push_model_extension(&mut self, extension: Envelope) -> &mut Self
pub fn push_model_extension(&mut self, extension: Envelope) -> &mut Self
Appends one provider-hosted extension.
Sourcepub fn extend_model_extensions(
&mut self,
extensions: impl IntoIterator<Item = Envelope>,
) -> &mut Self
pub fn extend_model_extensions( &mut self, extensions: impl IntoIterator<Item = Envelope>, ) -> &mut Self
Appends provider-hosted extensions in iteration order.
Sourcepub fn clear_model_extensions(&mut self) -> &mut Self
pub fn clear_model_extensions(&mut self) -> &mut Self
Removes every provider-hosted extension.
Trait Implementations§
Source§impl<M: Client> Debug for Config<M>
impl<M: Client> Debug for Config<M>
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
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.