pub struct PromptTemplate {
pub name: String,
pub system: Option<String>,
pub user_template: String,
pub include_lang_tags: bool,
}Expand description
Prompt template for code translation
Fields§
§name: StringTemplate name
system: Option<String>System prompt (optional)
user_template: StringUser prompt template with placeholders: {source_lang}, {target_lang}, {source_code}
Whether to include language tags
Implementations§
Source§impl PromptTemplate
impl PromptTemplate
Sourcepub fn instruction_following() -> Self
pub fn instruction_following() -> Self
Instruction-following style prompt (Alpaca/Vicuna format)
Sourcepub fn chat_style() -> Self
pub fn chat_style() -> Self
Chat-style prompt (ChatML format)
Sourcepub fn completion_style() -> Self
pub fn completion_style() -> Self
Completion-style prompt (minimal, for base models)
Sourcepub fn format(
&self,
source_lang: &str,
target_lang: &str,
source_code: &str,
) -> String
pub fn format( &self, source_lang: &str, target_lang: &str, source_code: &str, ) -> String
Format a prompt using this template
Sourcepub fn format_completion(&self, target_lang: &str, target_code: &str) -> String
pub fn format_completion(&self, target_lang: &str, target_code: &str) -> String
Format completion (target code with optional language tag)
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 Default for PromptTemplate
impl Default for PromptTemplate
Source§impl<'de> Deserialize<'de> for PromptTemplate
impl<'de> Deserialize<'de> for PromptTemplate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PromptTemplate
impl RefUnwindSafe for PromptTemplate
impl Send for PromptTemplate
impl Sync for PromptTemplate
impl Unpin for PromptTemplate
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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