feat: experimental AI support

This commit is contained in:
iff 2024-11-19 14:59:15 +01:00
parent 070343a5e2
commit 5d7624563d
6 changed files with 1312 additions and 0 deletions

View file

@ -56,6 +56,21 @@ pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Opti
}
}
#[cfg(feature = "request-ai")]{
use crate::requests::ai_suggestion;
let suggest = ai_suggestion(last_command, error_msg);
if let Some(suggest) = suggest {
eprintln!("{}: {}\n", t!("ai-suggestion").bold().blue(), suggest.note);
let command = suggest.command;
if command != "None" {
if PRIVILEGE_LIST.contains(&split_command[0].as_str()) {
return Some(format!("{} {}", split_command[0], command));
}
return Some(command);
}
}
}
None
}