MCPcopy Create free account
hub / github.com/ChenWu98/agent-attack / replace_target_caption

Function replace_target_caption

scripts/eval_step_attack.py:191–199  ·  view source on GitHub ↗
(obs_text: str, som_id: Union[int, List[int]], target_caption: str)

Source from the content-addressed store, hash-verified

189
190
191def replace_target_caption(obs_text: str, som_id: Union[int, List[int]], target_caption: str) -> str:
192 if isinstance(som_id, list):
193 modified_obs_text = obs_text
194 for idx in som_id:
195 modified_obs_text = _replace_target_caption(modified_obs_text, idx, target_caption)
196 print(f"Modified observation text: {modified_obs_text}")
197 return modified_obs_text
198 else:
199 return _replace_target_caption(obs_text, som_id, target_caption)
200
201
202def load(example: dict, attack: str, use_caption: bool, args) -> tuple:

Callers 1

loadFunction · 0.85

Calls 1

_replace_target_captionFunction · 0.85

Tested by

no test coverage detected