Create base.py
Browse files
prompt_injection/mutators/base.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python program showing
|
2 |
+
# abstract base class work
|
3 |
+
from abc import ABC, abstractmethod
|
4 |
+
from typing import List
|
5 |
+
|
6 |
+
class PromptMutator(ABC):
|
7 |
+
|
8 |
+
@abstractmethod
|
9 |
+
def mutate(self,sample:str)->str:
|
10 |
+
raise NotImplementedError
|
11 |
+
|
12 |
+
@abstractmethod
|
13 |
+
def get_name(self):
|
14 |
+
raise NotImplementedError
|
15 |
+
|
16 |
+
def mutate_batch(self,sample_list:List):
|
17 |
+
for sample in sample_list:
|
18 |
+
self.mutate_sample(sample)
|