diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-10 07:02:44 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-10 07:02:44 +0800 |
| commit | 4161eaa6c3ea0b6a10bd70d36f47bbbae0ae209c (patch) | |
| tree | 354998d30ededfd7e7bccf9a147cc29fd08c73ff /src | |
| parent | 0044399509dc26df4f0d1d776ca97edc73b041e5 (diff) | |
| download | aichat-4161eaa6c3ea0b6a10bd70d36f47bbbae0ae209c.tar.gz | |
fix: cli specify role is not applied when conversation_first set true (#57)
close #56
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/mod.rs | 10 | ||||
| -rw-r--r-- | src/main.rs | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 644d162..ebbd909 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -82,13 +82,17 @@ impl Config { let mut config: Config = serde_yaml::from_str(&content) .with_context(|| format!("Invalid config at {}", config_path.display()))?; config.load_roles()?; - if config.conversation_first { - config.start_conversation()?; - } Ok(config) } + pub fn on_repl(&mut self) -> Result<()> { + if self.conversation_first { + self.start_conversation()?; + } + Ok(()) + } + pub fn find_role(&self, name: &str) -> Option<Role> { self.roles.iter().find(|v| v.name == name).cloned() } diff --git a/src/main.rs b/src/main.rs index b940053..b198d14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,6 +98,7 @@ fn start_directive( fn start_interactive(client: ChatGptClient, config: SharedConfig) -> Result<()> { cl100k_base_singleton(); + config.lock().on_repl()?; let mut repl = Repl::init(config.clone())?; repl.run(client, config) } |
