Skip to content

Conversation

@ultmaster
Copy link
Contributor

This pull request refines the behavior of the Prompt class to allow reusability across multiple context blocks and introduces new tests to validate this functionality. The changes improve the flexibility of the Prompt class and ensure its state persists beyond the context block. Additionally, new tests were added to verify the updated behavior and introduce coverage for handling PDF-based prompts.

Enhancements to Prompt class behavior:

  • python/poml/prompt.py: Updated __enter__ method to preserve root elements across multiple with blocks, enabling the Prompt instance to be reused and extended.
  • python/poml/prompt.py: Modified __exit__ method to retain root elements after exiting the context block, allowing dump_xml and render to be called outside the with block.

Improvements to testing:

  • python/tests/test_basic.py: Removed unnecessary print statement in test_prompt for cleaner test output.
  • python/tests/test_basic.py: Added test_document to validate handling of PDF-based prompts, ensuring proper XML generation and rendering.
  • python/tests/test_basic.py: Introduced test_prompt_reuse_appendable to verify that a Prompt instance can be reused across multiple context blocks and extended incrementally.

Copilot AI review requested due to automatic review settings June 30, 2025 08:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refines the behavior of the Prompt class to support reuse across multiple context blocks while adding tests that validate the updated behavior including PDF-based prompts. Key changes include:

  • Updates in python/poml/prompt.py to modify enter and exit for preserving root elements outside the context block.
  • Adjustments in python/tests/test_basic.py to remove unnecessary output and introduce new tests covering PDF prompt handling and reusable Prompt instances.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
python/tests/test_basic.py Removed print statement in test_prompt and added tests for PDF documents and prompt reuse.
python/poml/prompt.py Modified enter and exit to persist root elements beyond context blocks for extended usage.

@ultmaster ultmaster merged commit 12a3d36 into main Jun 30, 2025
4 checks passed
@ultmaster ultmaster deleted the fix-python-base64 branch July 9, 2025 09:25
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