pub struct ContextFactory { /* private fields */ }Expand description
Multi-adapter context factory.
The factory maintains an ordered list of context adapters and composes
their output into a single ContextOutput.
Implementations§
Source§impl ContextFactory
impl ContextFactory
Sourcepub fn register<A>(&mut self, adapter: A)where
A: ContextAdapter + 'static,
pub fn register<A>(&mut self, adapter: A)where
A: ContextAdapter + 'static,
Registers a context adapter.
Sourcepub fn register_arc(&mut self, adapter: Arc<dyn ContextAdapter>)
pub fn register_arc(&mut self, adapter: Arc<dyn ContextAdapter>)
Registers an already shared context adapter.
Sourcepub fn adapter_names(&self) -> impl Iterator<Item = &str>
pub fn adapter_names(&self) -> impl Iterator<Item = &str>
Returns adapter names in registration order.
Sourcepub async fn build(&self, input: &ContextInput) -> ContextResult<ContextOutput>
pub async fn build(&self, input: &ContextInput) -> ContextResult<ContextOutput>
Builds context output by invoking all adapters in order.
§Errors
Returns ContextError::AdapterFailed when any adapter fails.
Sourcepub async fn build_request(
&self,
input: &ContextInput,
model: ModelName,
tool_specs: Option<&[ToolSpec]>,
) -> ContextResult<ChatRequest>
pub async fn build_request( &self, input: &ContextInput, model: ModelName, tool_specs: Option<&[ToolSpec]>, ) -> ContextResult<ChatRequest>
Builds a ChatRequest with context and optional tool specs.
Pass the tool specs slice (e.g. from
behest_tool::ToolRegistry::specs) instead of a typed registry
reference to keep behest-context free of a behest-tool dependency.
§Errors
Returns ContextError::AdapterFailed when any adapter fails.
Trait Implementations§
Source§impl Clone for ContextFactory
impl Clone for ContextFactory
Source§fn clone(&self) -> ContextFactory
fn clone(&self) -> ContextFactory
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ContextFactory
impl Default for ContextFactory
Source§fn default() -> ContextFactory
fn default() -> ContextFactory
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for ContextFactory
impl !UnwindSafe for ContextFactory
impl Freeze for ContextFactory
impl Send for ContextFactory
impl Sync for ContextFactory
impl Unpin for ContextFactory
impl UnsafeUnpin for ContextFactory
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