summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-10-08 09:47:03 +0800
committerGitHub <noreply@github.com>2024-10-08 09:47:03 +0800
commit91231e605f34b93d4e8e519e7a169ac61fa088ea (patch)
tree4b75710faac3e9da4534ef1ca914ea544a62259a
parentb3d31fd3d19b73caf41092e8f66e4263170bccf6 (diff)
downloadaichat-91231e605f34b93d4e8e519e7a169ac61fa088ea.tar.gz
feat: prelude supports <session>:<role> (#913)
-rw-r--r--config.example.yaml2
-rw-r--r--src/config/mod.rs8
2 files changed, 9 insertions, 1 deletions
diff --git a/config.example.yaml b/config.example.yaml
index 14f4986..9ca6692 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -19,7 +19,7 @@ mapping_tools: # Alias for a tool or toolset
use_tools: null # Which tools to use by default. (e.g. 'fs,web_search')
# ---- prelude ----
-prelude: null # Set a default role or session to start with (e.g. role:<name>, session:<name>)
+prelude: null # Set a default role or session to start with (e.g. role:<name>, session:<name>, <session>:<role>)
repl_prelude: null # Overrides the `prelude` setting specifically for conversations started in REPL
agent_prelude: null # Set a session to use when starting a agent. (e.g. temp, default)
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 97cd302..291d477 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -1398,6 +1398,14 @@ impl Config {
self.use_session(Some(name)).with_context(err_msg)?;
}
}
+ Some((session_name, role_name)) => {
+ if self.session.is_none() {
+ self.use_session(Some(session_name)).with_context(err_msg)?;
+ if let Some(true) = self.session.as_ref().map(|v| v.is_empty()) {
+ self.use_role(role_name).with_context(err_msg)?;
+ }
+ }
+ }
_ => {
bail!("{}", err_msg())
}