Insert an high energy API into combination
(prompt: Vec<String>, schedule: &Schedule)
| 31 | |
| 32 | /// Insert an high energy API into combination |
| 33 | fn prompt_insertion(prompt: Vec<String>, schedule: &Schedule) -> Vec<String> { |
| 34 | let mut combination = prompt; |
| 35 | let mut insert_num = 0; |
| 36 | loop { |
| 37 | let choose_api = schedule.choose_api_by_energy().to_string(); |
| 38 | if combination.contains(&choose_api) { |
| 39 | continue; |
| 40 | } |
| 41 | let ins_idx: usize = get_global_rng().gen::<usize>() % combination.len(); |
| 42 | log::info!("Insert {choose_api} into prompt."); |
| 43 | combination.insert(ins_idx, choose_api); |
| 44 | insert_num += 1; |
| 45 | if insert_num >= 3 { |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | combination |
| 50 | } |
| 51 | |
| 52 | fn prompt_energy_deletion(prompt: Vec<String>, schedule: &Schedule) -> Vec<String> { |
| 53 | let mut combination = prompt; |
no test coverage detected