20h20h20h cleanup

This commit is contained in:
legitnull 2023-02-17 11:59:31 -07:00
parent 0eed57a000
commit 632abc2706
2 changed files with 18 additions and 3 deletions

View File

@ -1,2 +1 @@
# G.1.R - GARBAGE INTERNET ROBOT

View File

@ -9,6 +9,7 @@ struct Config {
nick: String,
channels: Vec<String>,
openai: String,
model: String,
accents: String,
personalities: String,
}
@ -49,7 +50,7 @@ async fn ai(user_message: &str, username: &str, channel: &str) -> Vec<String> {
let chat_request = CreateCompletionRequestArgs::default()
.prompt(user_message)
.max_tokens(40_u16)
.model("text-davinci-003")
.model(config.model)
.build()
.unwrap();
let chat_response = client
@ -61,6 +62,21 @@ async fn ai(user_message: &str, username: &str, channel: &str) -> Vec<String> {
//modify regex for varible username ie G1R g1r GIR gir but as handle nick for bots
let response_text = &chat_response.choices.first().unwrap().text;
let regex = Regex::new(r#""|[gG][1iI][rR]:\s*|[mM][eE]:?\s"#).unwrap();
//let nick = &config.nick;
//let regex_str = format!(
// r#""|[{}{}{}]|\b[gG][1iI][rR]:\s*|\b[mM][eE]:?\s"#,
// nick.to_lowercase(),
// nick.to_uppercase(),
// nick.chars().map(|c| match c { /// regex magic nick removal in progress
// 'a' => '4',
// 'e' => '3',
// 'i' => '1',
// 'o' => '0',
// 's' => '5',
// _ => c,
// }).collect::<String>(),
//);
//let regex = Regex::new(&regex_str).unwrap();
let response_text = regex.replace_all(response_text, "").trim().to_string();
let response_lines = response_text.split("\n").filter(|line| !line.trim().is_empty());
let mut responses = Vec::new();