Skip to content

FIX: join score categories in pretty score output - #3014

Open
Ayoub (Ayoubhm07) wants to merge 1 commit into
microsoft:mainfrom
Ayoubhm07:fix/join-score-categories-pretty
Open

Ayoub (Ayoubhm07) wants to merge 1 commit into
microsoft:mainfrom
Ayoubhm07:fix/join-score-categories-pretty

Conversation

@Ayoubhm07

Copy link
Copy Markdown

Description

Closes #3013

PrettyScorePrinter._render_score interpolates score_category into an f-string, so the list repr reaches the operator's console:

      • Category: ['refusal', 'scams']    before
      • Category: refusal, scams          after

score_category has been list[str] since #1104, which touched no printer and left this one f-string behind. Everything else that renders it joins it with ", ": MarkdownScorePrinter (markdown.py:53), Score.__str__ (score.py:336), format_score_for_rationale (score_utils.py:85), and the web UI under the same Category label (frontend/src/components/Chat/MessageList.tsx:143). This applies the same line as its sibling in the same sub-package.

PrettyScorePrinter is also the default score printer for PrettyAttackResultPrinter (attack_result/pretty.py:59) and PrettyConversationPrinter (conversation/pretty.py:64), so their inline score block changes the same way. Category: [ currently appears 81 times across the 14 docs pages listed in doc/myst.yml; stored notebook outputs are not regenerated in this PR.

Category strings come from the scorer's LLM, and as in the markdown printer a \n inside one is not escaped escape_control_characters keeps tabs and newlines. Happy to escape it here instead if you would rather.

Tests and Documentation

Two tests in tests/unit/output/score/test_pretty.py: one for the join, one for the N/A path. Only the first fails on main; the N/A guard passes already and is there so the empty case stays covered.

pytest tests/unit/output/score/test_pretty.py   1 failed, 3 passed   before
                                                4 passed             after
pytest tests/unit/output/                       354 passed
ruff format --check, ruff check                  clean
ty check (both files, ty 0.0.84 from uv.lock)    clean

Windows 11, Python 3.11.9, ruff 0.16.10. No JupyText run: this PR changes no notebook and no docs file.

PrettyScorePrinter._render_score interpolated score_category into an
f-string, so the Python list repr reached the operator's console as
"Category: ['refusal', 'scams']". The field has been list[str] since
microsoft#1104, which touched no printer and left this f-string behind.

MarkdownScorePrinter, Score.__str__ and format_score_for_rationale all
join it with ", " already. Apply the same line as the sibling printer in
the same sub-package.

PrettyScorePrinter is the default score printer for the attack-result
and conversation printers, so their inline score block changes the same
way. Category strings come from the scorer's LLM and, as in the markdown
printer, a newline inside one is not escaped.
@Ayoubhm07

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: PrettyScorePrinter renders score_category as a Python list repr

1 participant