pub enum Template {
CompiledTemplate(String),
String(String),
Static(&'static str),
}
Expand description
A Template
defines a template for a prompt
Variants§
Implementations§
Source§impl Template
impl Template
Sourcepub fn from_compiled_template_name(name: impl Into<String>) -> Template
pub fn from_compiled_template_name(name: impl Into<String>) -> Template
Creates a reference to a template already stored in the repository
pub fn from_string(template: impl Into<String>) -> Template
Sourcepub async fn extend(tera: &Tera) -> Result<()>
pub async fn extend(tera: &Tera) -> Result<()>
Extends the prompt repository with a custom tera::Tera
instance.
If you have your own prompt templates or want to add other functionality, you can extend
the repository with your own tera::Tera
instance.
WARN: Do not use this inside a pipeline or any form of load, as it will lock the repository
§Errors
Errors if the repository could not be extended
Sourcepub async fn try_compiled_from_str(
template: impl AsRef<str> + Send + 'static,
) -> Result<Template>
pub async fn try_compiled_from_str( template: impl AsRef<str> + Send + 'static, ) -> Result<Template>
Compiles a template from a string and returns a Template
with a reference to the
string.
WARN: Do not use this inside a pipeline or any form of load, as it will lock the repository
§Errors
Errors if the template fails to compile
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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