MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / prompt_insertion

Function prompt_insertion

src/mutation.rs:33–50  ·  view source on GitHub ↗

Insert an high energy API into combination

(prompt: Vec<String>, schedule: &Schedule)

Source from the content-addressed store, hash-verified

31
32/// Insert an high energy API into combination
33fn 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
52fn prompt_energy_deletion(prompt: Vec<String>, schedule: &Schedule) -> Vec<String> {
53 let mut combination = prompt;

Callers 2

prompt_replacementFunction · 0.85
mutate_promptFunction · 0.85

Calls 2

get_global_rngFunction · 0.85
choose_api_by_energyMethod · 0.80

Tested by

no test coverage detected