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 # G.1.R - GARBAGE INTERNET ROBOT

View File

@ -9,6 +9,7 @@ struct Config {
nick: String, nick: String,
channels: Vec<String>, channels: Vec<String>,
openai: String, openai: String,
model: String,
accents: String, accents: String,
personalities: String, personalities: String,
} }
@ -49,7 +50,7 @@ async fn ai(user_message: &str, username: &str, channel: &str) -> Vec<String> {
let chat_request = CreateCompletionRequestArgs::default() let chat_request = CreateCompletionRequestArgs::default()
.prompt(user_message) .prompt(user_message)
.max_tokens(40_u16) .max_tokens(40_u16)
.model("text-davinci-003") .model(config.model)
.build() .build()
.unwrap(); .unwrap();
let chat_response = client 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 //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 response_text = &chat_response.choices.first().unwrap().text;
let regex = Regex::new(r#""|[gG][1iI][rR]:\s*|[mM][eE]:?\s"#).unwrap(); 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_text = regex.replace_all(response_text, "").trim().to_string();
let response_lines = response_text.split("\n").filter(|line| !line.trim().is_empty()); let response_lines = response_text.split("\n").filter(|line| !line.trim().is_empty());
let mut responses = Vec::new(); let mut responses = Vec::new();