pub struct PromptLoader { /* private fields */ }Expand description
Loads and caches prompt files from a directory.
Implementations§
Source§impl PromptLoader
impl PromptLoader
Sourcepub fn new(base_dir: impl Into<PathBuf>) -> Self
pub fn new(base_dir: impl Into<PathBuf>) -> Self
Create a new prompt loader rooted at the given directory.
Sourcepub fn load(&self, relative_path: &str) -> Result<String, PromptError>
pub fn load(&self, relative_path: &str) -> Result<String, PromptError>
Load a prompt file by relative path (e.g., “system.md”, “roles/explorer.md”). Returns cached version if already loaded.
Sourcepub fn load_merged(&self, paths: &[&str]) -> Result<String, PromptError>
pub fn load_merged(&self, paths: &[&str]) -> Result<String, PromptError>
Load and merge multiple prompt files, separated by newlines.
Sourcepub fn load_with_vars(
&self,
path: &str,
vars: &HashMap<String, String>,
) -> Result<String, PromptError>
pub fn load_with_vars( &self, path: &str, vars: &HashMap<String, String>, ) -> Result<String, PromptError>
Load a prompt with variable substitution. Variables are {{key}} patterns in the template.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the cache, forcing reload on next access.
Auto Trait Implementations§
impl !Freeze for PromptLoader
impl RefUnwindSafe for PromptLoader
impl Send for PromptLoader
impl Sync for PromptLoader
impl Unpin for PromptLoader
impl UnsafeUnpin for PromptLoader
impl UnwindSafe for PromptLoader
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