Skip to content

FEAT: Add support for safe image outputs in console printer, file output in markdown printer#1659

Open
fdubut wants to merge 9 commits intomicrosoft:mainfrom
fdubut:printer_updates
Open

FEAT: Add support for safe image outputs in console printer, file output in markdown printer#1659
fdubut wants to merge 9 commits intomicrosoft:mainfrom
fdubut:printer_updates

Conversation

@fdubut
Copy link
Copy Markdown
Contributor

@fdubut fdubut commented Apr 27, 2026

Description

  • Add support for "safe outputs" in the console printer (reduce cognitive load for harmful images).
    • New optional parameter safe_outputs in the constructor, defaults to False (no breaking change).
  • Add support for file output in the Markdown printer.
    • Design choices: outputs to either file or standard output (not both), always append to file (no overwrite).

Tests and Documentation

  • Added tests for the Markdown printer and the underlying display_response (for console printer).

Comment on lines +54 to +60
if safe_outputs:
new_width = int(image.width * 0.5)
new_height = int(image.height * 0.5)
image = image.resize((new_width, new_height), Image.Resampling.LANCZOS)

image = ImageEnhance.Color(image).enhance(0.0)
image = image.rotate(90.0, expand=True, fillcolor=(255, 255, 255))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the rotation and the other changes? Blurring seems more appropriate?

logger = logging.getLogger(__name__)


async def display_image_response(response_piece: MessagePiece, safe_outputs: bool = False) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"safe" implies that we hide only unsafe ones. Maybe hide_outputs or blur_outputs or similar would be preferable? Also, this only applies to images, not all outputs.

I also don't want to turn this on in our example notebooks because the entire point is to illustrate how the package works. We can show it in one of them, of course.

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.

2 participants