PromptShieldTarget drops prompt text after each </document> tag
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先定位 PromptShieldTarget._input_parser,并将其循环与类 docstring 中的示例进行比较。使用提供的输入复现该问题,然后确保每个 标签之后的文本以及文档之间的文本仍保留在 userPrompt 中,同时文档内容仍会被收集;如果有可用的相关 PromptShieldTarget 测试,请重新运行它们。
由索引模型根据 Issue 内容生成。
描述
what happens
PromptShieldTarget._input_parser drops every piece of text that comes after a closing </document> tag. the loop keeps only the segment before each closing tag as the document and never appends contents[1], so trailing prompt text and text between documents is silently excluded from the userPrompt sent to Azure Prompt Shield.
for prefix question <document> doc1 </document> trailing question <document> doc2 </document> end text, the parsed userPrompt is just prefix question and the jailbreak scan never sees trailing question or end text.
repro
input_str = 'q1 <document> d1 </document> q2 <document> d2 </document> q3'
user_prompt = ""
documents = []
for element in input_str.split("<document>"):
contents = element.split("</document>")
if len(contents) == 1:
user_prompt += contents[0]
else:
documents.append(contents[0])
print(repr(user_prompt)) # 'q1 ' — q2 and q3 are gone
expected
text after each closing tag flows into the userPrompt, matching how the example in the class docstring reads.
env: main 5503ecb
- 主要语言
- Python
- 星标
- 4.5k
- 派生
- 896
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 206
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/PyRIT#2888 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 91/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
Bug: triage GUI help wanted
难度 2/5 1-3 小时 新手友好度 86/100
microsoft/PyRIT#2868 · 1 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-2 天 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 7 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
lmstudio-ai/mlx-engine#376 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
pyiron/bagofholding#166 ·