diff options
| author | sigoden <sigoden@gmail.com> | 2023-11-27 15:39:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-27 15:39:55 +0800 |
| commit | 2508d56598a37844e369ab623ceb5bc7b2c78d38 (patch) | |
| tree | 744986163dcfe09aade1ef61ef63ad21279666cc /src/config/mod.rs | |
| parent | 25e545474fcbd69dfb2a283981178491717cc6b5 (diff) | |
| download | aichat-2508d56598a37844e369ab623ceb5bc7b2c78d38.tar.gz | |
feat: state-aware completer (#251)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 08509be..1b3d802 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -283,6 +283,24 @@ impl Config { Ok(()) } + pub fn get_state(&self) -> State { + if let Some(session) = &self.session { + if session.is_empty() { + if session.role.is_some() { + State::EmptySessionWithRole + } else { + State::EmptySession + } + } else { + State::Session + } + } else if self.role.is_some() { + State::Role + } else { + State::Normal + } + } + pub fn get_temperature(&self) -> Option<f64> { self.temperature } @@ -806,6 +824,15 @@ impl Keybindings { } } +#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] +pub enum State { + Normal, + Role, + EmptySession, + EmptySessionWithRole, + Session, +} + fn create_config_file(config_path: &Path) -> Result<()> { let ans = Confirm::new("No config file, create a new one?") .with_default(true) |
