pub struct TemplateContext { /* private fields */ }Expand description
Context for template-based prompt generation.
Provides access to the template registry for loading user-customizable templates. This context is created from the application config and passed to prompt generation functions.
§Example
ⓘ
let context = TemplateContext::from_user_templates_dir(Some(PathBuf::from("~/.config/ralph/templates")));
let prompt = prompt_developer_iteration_xml_with_context(
&context,
1, 5, ContextLevel::Normal, "prompt", "plan"
);Implementations§
Source§impl TemplateContext
impl TemplateContext
Sourcepub const fn new(registry: TemplateRegistry) -> Self
pub const fn new(registry: TemplateRegistry) -> Self
Create a new template context with the given registry.
Sourcepub const fn from_user_templates_dir(
user_templates_dir: Option<PathBuf>,
) -> Self
pub const fn from_user_templates_dir( user_templates_dir: Option<PathBuf>, ) -> Self
Create a template context from a config’s user templates directory.
This is the recommended way to create a TemplateContext as it
respects the user’s configured templates directory.
Sourcepub const fn registry(&self) -> &TemplateRegistry
pub const fn registry(&self) -> &TemplateRegistry
Get a reference to the template registry.
Trait Implementations§
Source§impl Clone for TemplateContext
impl Clone for TemplateContext
Source§fn clone(&self) -> TemplateContext
fn clone(&self) -> TemplateContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TemplateContext
impl Debug for TemplateContext
Auto Trait Implementations§
impl Freeze for TemplateContext
impl RefUnwindSafe for TemplateContext
impl Send for TemplateContext
impl Sync for TemplateContext
impl Unpin for TemplateContext
impl UnwindSafe for TemplateContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more