From a17f349daa0609402c51205929b9f2b32f6fb1bb Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 24 Apr 2024 16:12:38 +0800 Subject: feat: support customizing `top_p` parameter (#434) --- src/config/role.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/config/role.rs') diff --git a/src/config/role.rs b/src/config/role.rs index 50d5b5e..b226622 100644 --- a/src/config/role.rs +++ b/src/config/role.rs @@ -16,12 +16,10 @@ pub const INPUT_PLACEHOLDER: &str = "__INPUT__"; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Role { - /// Role name pub name: String, - /// Prompt text pub prompt: String, - /// Temperature value pub temperature: Option, + pub top_p: Option, } impl Role { @@ -30,6 +28,7 @@ impl Role { name: TEMP_ROLE.into(), prompt: prompt.into(), temperature: None, + top_p: None, } } @@ -67,6 +66,7 @@ If there is a lack of details, provide most logical solution. Output plain text only, without any markdown formatting."# ), temperature: None, + top_p: None, } } @@ -79,6 +79,7 @@ Provide short responses in about 80 words. APPLY MARKDOWN formatting when possible."# .into(), temperature: None, + top_p: None, } } @@ -89,6 +90,7 @@ APPLY MARKDOWN formatting when possible."# If there is a lack of details, provide most logical solution, without requesting further clarification."# .into(), temperature: None, + top_p: None, } } @@ -106,6 +108,10 @@ If there is a lack of details, provide most logical solution, without requesting self.temperature = value; } + pub fn set_top_p(&mut self, value: Option) { + self.top_p = value; + } + pub fn complete_prompt_args(&mut self, name: &str) { self.name = name.to_string(); self.prompt = complete_prompt_args(&self.prompt, &self.name); -- cgit v1.2.3