mirror of
https://github.com/sigoden/aichat
synced 2024-11-18 09:28:27 +00:00
refactor: trivial updates
- change prompt's temp role name - questionnaire of 'save chat messages' default set true - `.info` do not show role name
This commit is contained in:
parent
05d20f207f
commit
c45d71cdea
@ -24,7 +24,7 @@ const CONFIG_FILE_NAME: &str = "config.yaml";
|
|||||||
const ROLES_FILE_NAME: &str = "roles.yaml";
|
const ROLES_FILE_NAME: &str = "roles.yaml";
|
||||||
const HISTORY_FILE_NAME: &str = "history.txt";
|
const HISTORY_FILE_NAME: &str = "history.txt";
|
||||||
const MESSAGE_FILE_NAME: &str = "messages.md";
|
const MESSAGE_FILE_NAME: &str = "messages.md";
|
||||||
const TEMP_ROLE_NAME: &str = "%PROMPT%";
|
const TEMP_ROLE_NAME: &str = "P";
|
||||||
const SET_COMPLETIONS: [&str; 9] = [
|
const SET_COMPLETIONS: [&str; 9] = [
|
||||||
".set api_key",
|
".set api_key",
|
||||||
".set temperature",
|
".set temperature",
|
||||||
@ -241,16 +241,10 @@ impl Config {
|
|||||||
.temperature
|
.temperature
|
||||||
.map(|v| v.to_string())
|
.map(|v| v.to_string())
|
||||||
.unwrap_or("-".into());
|
.unwrap_or("-".into());
|
||||||
let role_name = self
|
|
||||||
.role
|
|
||||||
.as_ref()
|
|
||||||
.map(|v| v.name.to_string())
|
|
||||||
.unwrap_or("-".into());
|
|
||||||
let items = vec![
|
let items = vec![
|
||||||
("config_file", file_info(&Config::config_file()?)),
|
("config_file", file_info(&Config::config_file()?)),
|
||||||
("roles_file", file_info(&Config::roles_file()?)),
|
("roles_file", file_info(&Config::roles_file()?)),
|
||||||
("messages_file", file_info(&Config::messages_file()?)),
|
("messages_file", file_info(&Config::messages_file()?)),
|
||||||
("role", role_name),
|
|
||||||
("api_key", self.api_key.clone()),
|
("api_key", self.api_key.clone()),
|
||||||
("temperature", temperature),
|
("temperature", temperature),
|
||||||
("save", self.save.to_string()),
|
("save", self.save.to_string()),
|
||||||
@ -396,7 +390,7 @@ pub struct Role {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_config_file(config_path: &Path) -> Result<()> {
|
fn create_config_file(config_path: &Path) -> Result<()> {
|
||||||
let confirm_map_err = |_| anyhow!("Error with questionnaire, try again later");
|
let confirm_map_err = |_| anyhow!("Not finish questionnaire, try again later.");
|
||||||
let text_map_err = |_| anyhow!("An error happened when asking for your key, try again later.");
|
let text_map_err = |_| anyhow!("An error happened when asking for your key, try again later.");
|
||||||
let ans = Confirm::new("No config file, create a new one?")
|
let ans = Confirm::new("No config file, create a new one?")
|
||||||
.with_default(true)
|
.with_default(true)
|
||||||
@ -420,7 +414,7 @@ fn create_config_file(config_path: &Path) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ans = Confirm::new("Save chat messages")
|
let ans = Confirm::new("Save chat messages")
|
||||||
.with_default(false)
|
.with_default(true)
|
||||||
.prompt()
|
.prompt()
|
||||||
.map_err(confirm_map_err)?;
|
.map_err(confirm_map_err)?;
|
||||||
if ans {
|
if ans {
|
||||||
|
Loading…
Reference in New Issue
Block a user