summaryrefslogtreecommitdiffstats
path: root/src/config/role.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-04-20 09:21:52 +0800
committerGitHub <noreply@github.com>2024-04-20 09:21:52 +0800
commit5d763fc10c4e3d40268ead473ccb0000b4923bd1 (patch)
tree5c8e498edfed073dc4e82f34cfb96a3f18c7ad7c /src/config/role.rs
parent8b806db85791a23f9725adbe09f414464adb6605 (diff)
downloadaichat-5d763fc10c4e3d40268ead473ccb0000b4923bd1.tar.gz
feat: add `.prompt` repl command (#420)
Diffstat (limited to 'src/config/role.rs')
-rw-r--r--src/config/role.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/config/role.rs b/src/config/role.rs
index 5a6ff3a..50d5b5e 100644
--- a/src/config/role.rs
+++ b/src/config/role.rs
@@ -7,6 +7,7 @@ use crate::{
use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
+pub const TEMP_ROLE: &str = "%%";
pub const SHELL_ROLE: &str = "%shell%";
pub const EXPLAIN_ROLE: &str = "%explain%";
pub const CODE_ROLE: &str = "%code%";
@@ -24,6 +25,14 @@ pub struct Role {
}
impl Role {
+ pub fn temp(prompt: &str) -> Self {
+ Self {
+ name: TEMP_ROLE.into(),
+ prompt: prompt.into(),
+ temperature: None,
+ }
+ }
+
pub fn find_system_role(name: &str) -> Option<Self> {
match name {
SHELL_ROLE => Some(Self::shell()),