diff options
| author | sigoden <sigoden@gmail.com> | 2024-12-01 10:06:20 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-01 10:06:20 +0800 |
| commit | 7e8e2a6ce6d96ffa31c202ead6f31f18dc73c618 (patch) | |
| tree | 907070ab6f81ebef46a1ae8793b553c99b2dd52e /src/config | |
| parent | efdec3497976ddb2e35e6302ee68f3d753f837a3 (diff) | |
| download | aichat-7e8e2a6ce6d96ffa31c202ead6f31f18dc73c618.tar.gz | |
feat: append shell execute command to history file (#1026)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 39c63a3..e0e1efa 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -137,6 +137,7 @@ pub struct Config { pub serve_addr: Option<String>, pub user_agent: Option<String>, + pub append_command_to_history_file: bool, pub clients: Vec<ClientConfig>, @@ -206,6 +207,7 @@ impl Default for Config { serve_addr: None, user_agent: None, + append_command_to_history_file: true, clients: vec![], @@ -1950,7 +1952,7 @@ impl Config { if output.is_empty() || !self.save { return Ok(()); } - let timestamp = now(); + let now = now(); let summary = input.summary(); let raw_input = input.raw(); let scope = if self.agent.is_none() { @@ -1983,7 +1985,7 @@ impl Config { None => String::new(), }; let output = format!( - "# CHAT: {summary} [{timestamp}]{scope}\n{raw_input}\n--------\n{tool_calls}{output}\n--------\n\n", + "# CHAT: {summary} [{now}]{scope}\n{raw_input}\n--------\n{tool_calls}{output}\n--------\n\n", ); file.write_all(output.as_bytes()) .with_context(|| "Failed to save message") @@ -2225,6 +2227,9 @@ impl Config { if let Some(v) = read_env_value::<String>(&get_env_name("user_agent")) { self.user_agent = v; } + if let Some(Some(v)) = read_env_bool(&get_env_name("append_command_to_history_file")) { + self.append_command_to_history_file = v; + } } fn load_functions(&mut self) -> Result<()> { |
