Files
EvoSynth/jailbreak_toolbox/attacks/base_attack.py
dongdongunique f3af94df0b first commit
2025-12-10 00:54:02 +08:00

23 lines
639 B
Python

from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, List, Dict
from ..models.base_model import BaseModel
@dataclass
class AttackResult:
target: Any
success: bool = False
final_prompt: str = ""
output_text: str = ""
history: List[Dict[str, Any]] = field(default_factory=list)
cost: Dict[str, float] = field(default_factory=dict)
method: str = ""
image_path: str = ""
class BaseAttack(ABC):
def __init__(self, model: BaseModel, **kwargs):
self.model = model
@abstractmethod
def attack(self, target: Any) -> AttackResult:
pass