RemoveRuleByName removes the first rule with the given name from the slice and returns the resulting slice. Used to delete a rule after it fires.
(rules []config.ToolCallInjectionRule, name string)
| 260 | // RemoveRuleByName removes the first rule with the given name from the slice |
| 261 | // and returns the resulting slice. Used to delete a rule after it fires. |
| 262 | func RemoveRuleByName(rules []config.ToolCallInjectionRule, name string) []config.ToolCallInjectionRule { |
| 263 | for i, r := range rules { |
| 264 | if r.Name == name { |
| 265 | return append(rules[:i], rules[i+1:]...) |
| 266 | } |
| 267 | } |
| 268 | return rules |
| 269 | } |
| 270 | |
| 271 | func randomHex(n int) string { |
| 272 | b := make([]byte, n) |