pub struct FewShotPrompt { /* private fields */ }Expand description
Few-shot prompt builder
Constructs prompts using few-shot learning by providing examples before the actual query.
Implementations§
Source§impl FewShotPrompt
impl FewShotPrompt
Sourcepub fn new(instruction: impl Into<String>) -> Self
pub fn new(instruction: impl Into<String>) -> Self
Create a new few-shot prompt with an instruction
Sourcepub fn add_example(
&mut self,
input: impl Into<String>,
output: impl Into<String>,
) -> &mut Self
pub fn add_example( &mut self, input: impl Into<String>, output: impl Into<String>, ) -> &mut Self
Add an example
Sourcepub fn add_examples(&mut self, examples: Vec<Example>) -> &mut Self
pub fn add_examples(&mut self, examples: Vec<Example>) -> &mut Self
Add multiple examples
Sourcepub fn set_query(&mut self, query: impl Into<String>) -> &mut Self
pub fn set_query(&mut self, query: impl Into<String>) -> &mut Self
Set the query (the actual input to process)
Sourcepub fn with_prefixes(
&mut self,
input_prefix: impl Into<String>,
output_prefix: impl Into<String>,
) -> &mut Self
pub fn with_prefixes( &mut self, input_prefix: impl Into<String>, output_prefix: impl Into<String>, ) -> &mut Self
Set custom input/output prefixes
Sourcepub fn with_separator(&mut self, separator: impl Into<String>) -> &mut Self
pub fn with_separator(&mut self, separator: impl Into<String>) -> &mut Self
Set custom separator between examples
Trait Implementations§
Source§impl Clone for FewShotPrompt
impl Clone for FewShotPrompt
Source§fn clone(&self) -> FewShotPrompt
fn clone(&self) -> FewShotPrompt
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 moreAuto Trait Implementations§
impl Freeze for FewShotPrompt
impl RefUnwindSafe for FewShotPrompt
impl Send for FewShotPrompt
impl Sync for FewShotPrompt
impl Unpin for FewShotPrompt
impl UnwindSafe for FewShotPrompt
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