pub struct HumanMessagePromptTemplate { /* private fields */ }Expand description
Struct HumanMessagePromptTemplate defines a template for creating human (user) messages.
PromptTemplate is used to generate the message template.
§Usage
ⓘ
let human_message_prompt = HumanMessagePromptTemplate::new(template_fstring!(
"User says: {content}",
"content",
));§Images
with_images names an input variable that holds images to
attach to the message, so a chain or agent can take them like any other input:
ⓘ
let prompt = HumanMessagePromptTemplate::new(template_fstring!("{input}", "input"))
.with_images("images");
chain.invoke(prompt_args! {
"input" => "What is in this picture?",
"images" => ["https://example.com/cat.png"],
}).await?;Implementations§
Source§impl HumanMessagePromptTemplate
impl HumanMessagePromptTemplate
pub fn new(prompt: PromptTemplate) -> Self
Sourcepub fn with_images<S: Into<String>>(self, key: S) -> Self
pub fn with_images<S: Into<String>>(self, key: S) -> Self
Attaches the images found in the key input variable to the message.
The variable can be one image or a list of them. An image is either a string
(an http(s) URL, a data: URL or bare base64 data) or an
ImageContent object ({"image_url": "...", "detail": "low"}).
A missing variable, null or an empty list means no images.
Trait Implementations§
Source§impl Clone for HumanMessagePromptTemplate
impl Clone for HumanMessagePromptTemplate
Source§impl FormatPrompter for HumanMessagePromptTemplate
impl FormatPrompter for HumanMessagePromptTemplate
fn format_prompt( &self, input_variables: PromptArgs, ) -> Result<PromptValue, PromptError>
fn get_input_variables(&self) -> Vec<String>
Source§fn format_prompt_async<'life0, 'async_trait>(
&'life0 self,
input_variables: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<PromptValue, PromptError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn format_prompt_async<'life0, 'async_trait>(
&'life0 self,
input_variables: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<PromptValue, PromptError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Formats the prompt, for prompts that need async work to do it (e.g. a
FewShotPromptTemplate choosing examples by embedding similarity). Chains call
this one. Defaults to format_prompt.Source§impl MessageFormatter for HumanMessagePromptTemplate
impl MessageFormatter for HumanMessagePromptTemplate
fn format_messages( &self, input_variables: PromptArgs, ) -> Result<Vec<Message>, PromptError>
Source§fn input_variables(&self) -> Vec<String>
fn input_variables(&self) -> Vec<String>
Returns a list of required input variable names for the template.
Auto Trait Implementations§
impl Freeze for HumanMessagePromptTemplate
impl RefUnwindSafe for HumanMessagePromptTemplate
impl Send for HumanMessagePromptTemplate
impl Sync for HumanMessagePromptTemplate
impl Unpin for HumanMessagePromptTemplate
impl UnsafeUnpin for HumanMessagePromptTemplate
impl UnwindSafe for HumanMessagePromptTemplate
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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