fix: cli specify role is not applied when conversation_first set true (#57)

close #56
This commit is contained in:
sigoden 2023-03-10 07:02:44 +08:00 committed by GitHub
parent 0044399509
commit 4161eaa6c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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()
}

View File

@ -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)
}