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

Function _replace_target_caption

scripts/eval_step_attack.py:183–188  ·  view source on GitHub ↗
(obs_text: str, som_id: int, target_caption: str)

Source from the content-addressed store, hash-verified

181
182
183def _replace_target_caption(obs_text: str, som_id: int, target_caption: str) -> str:
184 # Match the first description content in "description: <caption (may contain ",")>, url"
185 prefix = obs_text[: obs_text.index(f"\n[{som_id}]")]
186 obs_text = obs_text[obs_text.index(f"\n[{som_id}]") :]
187 modified_obs_text = re.sub(r"description: (.*?), url", f"description: {target_caption}, url", obs_text, count=1)
188 return prefix + modified_obs_text
189
190
191def replace_target_caption(obs_text: str, som_id: Union[int, List[int]], target_caption: str) -> str:

Callers 1

replace_target_captionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected