mirror of
https://github.com/sigoden/aichat
synced 2024-11-18 09:28:27 +00:00
fix: cli specify role is not applied when conversation_first set true (#57)
close #56
This commit is contained in:
parent
0044399509
commit
4161eaa6c3
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user