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