diff options
| author | sigoden <sigoden@gmail.com> | 2024-12-01 07:28:12 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-01 07:28:12 +0800 |
| commit | 431d16363ede42f299dbd32c4e38390713620809 (patch) | |
| tree | d49f1a25ea152ab9e6be9117b67f0acbe9115164 /src/config/session.rs | |
| parent | 50bbfc4541bf2cb2ecb28f2fed3b9b3ab7d5005b (diff) | |
| download | aichat-431d16363ede42f299dbd32c4e38390713620809.tar.gz | |
feat: agent supports dynamic instructions (#1023)
* feat: agent supports dynamic instructions
* change tool calls' null output to 'TODO'
* REPL don't print banner if use agent/rag
Diffstat (limited to 'src/config/session.rs')
| -rw-r--r-- | src/config/session.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/config/session.rs b/src/config/session.rs index 4b3da76..820fa12 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -36,6 +36,8 @@ pub struct Session { role_name: Option<String>, #[serde(default, skip_serializing_if = "IndexMap::is_empty")] agent_variables: AgentVariables, + #[serde(default, skip_serializing_if = "String::is_empty")] + agent_instructions: String, #[serde(default, skip_serializing_if = "Vec::is_empty")] compressed_messages: Vec<Message>, @@ -275,19 +277,21 @@ impl Session { self.role_prompt.clear(); } - pub fn sync_agent(&mut self, agent: &Agent, set_dirty: bool) { + pub fn sync_agent(&mut self, agent: &Agent) { self.role_name = None; self.role_prompt = agent.interpolated_instructions(); self.agent_variables = agent.variables().clone(); - if set_dirty { - self.dirty = true; - } + self.agent_instructions = self.role_prompt.clone(); } pub fn agent_variables(&self) -> &AgentVariables { &self.agent_variables } + pub fn agent_instructions(&self) -> &str { + &self.agent_instructions + } + pub fn set_save_session(&mut self, value: Option<bool>) { if self.save_session != value { self.save_session = value; |
