BUG: CharacterSpaceConverter introduces whitespace holes and trailing whitespace
维护者通常 2 天内回复
评估
调研方向
在 PyRIT 源代码中找到 CharacterSpaceConverter 及其测试。阅读转换器的实现,并先运行现有的转换器测试;为单词之间的标点、缩写形式和末尾标点添加测试覆盖。完成标准是:在插入空格之前移除标点,输出与示例一致,并且标点模式在模块级别只编译一次。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
CharacterSpaceConverter spaces out characters with " ".join(prompt) before removing punctuation with re.sub(...). This order of operations introduces whitespace artifacts:
- Stripping punctuation leaves empty character "holes", producing 4 spaces between words (e.g.,
"Hello, world"->"H e l l o w o r l d"instead of the standard 3-space inter-word spacing"H e l l o w o r l d"). - Contractions or mid-word punctuation leave double spaces (e.g.,
"How's"->"H o w s"instead of"H o w s"). - Trailing punctuation leaves unwanted trailing whitespace (e.g.,
"hello!"->"h e l l o ").
Additionally, the punctuation regex is recompiled on every invocation of convert_async rather than precompiled at module level.
Steps/Code to Reproduce
import asyncio
from pyrit.converter import CharacterSpaceConverter
async def main():
converter = CharacterSpaceConverter()
res1 = await converter.convert_async(prompt="hello!")
print(repr(res1.output_text)) # prints 'h e l l o ' with trailing space
res2 = await converter.convert_async(prompt="Hello, world! How's everything?")
print(repr(res2.output_text)) # prints 'H e l l o w o r l d H o w s e v e r y t h i n g '
asyncio.run(main())
Expected Results
Punctuation should be stripped prior to character spacing so spacing remains uniform without artificial gaps or trailing whitespace:
"hello!"->'h e l l o'"Hello, world! How's everything?"->'H e l l o w o r l d H o w s e v e r y t h i n g'
Actual Results
'h e l l o ''H e l l o w o r l d H o w s e v e r y t h i n g '
Versions
- OS: Windows 11
- Python version: 3.12
- PyRIT version: main
- 主要语言
- Python
- 星标
- 4.7k
- 派生
- 1k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 510
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
BUG: HuggingFaceChatTarget runs model.generate() on the event loop可能已有人在做 @Shizoqua 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
-
BUG: StaticPromptInjectionScorer misses modern frontier chat template delimiters (DeepSeek, Cohere Command R, Mistral)可能已有人在做 @Kaap10 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
Parameter required status is lost after wire round-trip可能已有人在做 @its-amann 于 3 天前认领。 未关闭Bug: triage help wanted
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/PyRIT#3854 · 2 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
BUG: LLMGenericTextConverter identifier changes between processes for set-valued template parameters可能已有人在做 @samrudhi03 于 3 天前认领。 未关闭Bug: triage
难度 2/5 1-3 小时 新手友好度 75/100
microsoft/PyRIT#3841 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
BUG: SelfAskGeneral scorers leave their output keys out of the identifier可能已有人在做 @Hrushikesh-ramilla 于 4 天前认领。 未关闭Bug: triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
相似的 Issue
-
ChatBedrockConverse changes the keys of JSON tool results to camelCase (`order_id` becomes `orderId`)可能已有人在做 @geyazheng 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
langchain-ai/langchain-aws#1469 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
b4b usability
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
fix(schedule): align list_tasks since cursor filter boundary from strict > to >=可能已有人在做 @bfs2021 今天认领。 未关闭agent-ready bug p2 schedule
难度 2/5 1-3 小时 新手友好度 83/100
allenporter/supernote#540 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
frazane/scoringrules#164 ·
维护者通常 1 天内回复