diff options
| author | sigoden <sigoden@gmail.com> | 2024-04-24 16:12:38 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-24 16:12:38 +0800 |
| commit | a17f349daa0609402c51205929b9f2b32f6fb1bb (patch) | |
| tree | 380dd9c158f8d9278355634a8d474df3a90f8d25 /src/config/role.rs | |
| parent | 040c48b9b392e3329d3f1de8eeb1b8773129773c (diff) | |
| download | aichat-a17f349daa0609402c51205929b9f2b32f6fb1bb.tar.gz | |
feat: support customizing `top_p` parameter (#434)
Diffstat (limited to 'src/config/role.rs')
| -rw-r--r-- | src/config/role.rs | 12 |
1 files changed, 9 insertions, 3 deletions
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<f64>, + pub top_p: Option<f64>, } 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<f64>) { + 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); |
