pub struct PromptTemplate {
pub base_template: String,
pub system_message: Option<String>,
pub example_template: String,
pub format_type: FormatType,
pub provider_type: ProviderType,
pub max_examples: Option<usize>,
pub include_reasoning: bool,
}
Expand description
Advanced prompt template with dynamic variables and provider adaptation
Fields§
§base_template: String
Base template string with variable placeholders
system_message: Option<String>
System message for providers that support it
example_template: String
Template for formatting examples
format_type: FormatType
Output format type
provider_type: ProviderType
Target provider type for optimization
max_examples: Option<usize>
Maximum number of examples to include
include_reasoning: bool
Whether to include reasoning instructions
Implementations§
Source§impl PromptTemplate
impl PromptTemplate
Sourcepub fn new(format_type: FormatType, provider_type: ProviderType) -> Self
pub fn new(format_type: FormatType, provider_type: ProviderType) -> Self
Create a new prompt template
Sourcepub fn for_provider(
provider_type: ProviderType,
format_type: FormatType,
) -> Self
pub fn for_provider( provider_type: ProviderType, format_type: FormatType, ) -> Self
Create template optimized for specific provider
Sourcepub fn with_max_examples(self, max: usize) -> Self
pub fn with_max_examples(self, max: usize) -> Self
Set maximum number of examples
Sourcepub fn with_system_message(self, message: String) -> Self
pub fn with_system_message(self, message: String) -> Self
Set system message
Sourcepub fn with_reasoning(self, enable: bool) -> Self
pub fn with_reasoning(self, enable: bool) -> Self
Enable or disable reasoning instructions
Sourcepub fn with_base_template(self, template: String) -> Self
pub fn with_base_template(self, template: String) -> Self
Set custom base template
Trait Implementations§
Source§impl Clone for PromptTemplate
impl Clone for PromptTemplate
Source§fn clone(&self) -> PromptTemplate
fn clone(&self) -> PromptTemplate
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 PromptTemplate
impl Debug for PromptTemplate
Source§impl TemplateRenderer for PromptTemplate
impl TemplateRenderer for PromptTemplate
Source§fn render(&self, context: &PromptContext) -> LangExtractResult<String>
fn render(&self, context: &PromptContext) -> LangExtractResult<String>
Render the template with the given context
Source§fn validate(&self) -> LangExtractResult<()>
fn validate(&self) -> LangExtractResult<()>
Validate the template structure
Source§fn required_variables(&self) -> Vec<String>
fn required_variables(&self) -> Vec<String>
Get required variables for this template
Auto Trait Implementations§
impl Freeze for PromptTemplate
impl RefUnwindSafe for PromptTemplate
impl Send for PromptTemplate
impl Sync for PromptTemplate
impl Unpin for PromptTemplate
impl UnwindSafe for PromptTemplate
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