Validate base64 and render outside Prompt with-blocks#35
Merged
Conversation
Contributor
There was a problem hiding this comment.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refines the behavior of the
Promptclass to allow reusability across multiple context blocks and introduces new tests to validate this functionality. The changes improve the flexibility of thePromptclass 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
Promptclass behavior:python/poml/prompt.py: Updated__enter__method to preserve root elements across multiplewithblocks, enabling thePromptinstance to be reused and extended.python/poml/prompt.py: Modified__exit__method to retain root elements after exiting the context block, allowingdump_xmlandrenderto be called outside thewithblock.Improvements to testing:
python/tests/test_basic.py: Removed unnecessaryprintstatement intest_promptfor cleaner test output.python/tests/test_basic.py: Addedtest_documentto validate handling of PDF-based prompts, ensuring proper XML generation and rendering.python/tests/test_basic.py: Introducedtest_prompt_reuse_appendableto verify that aPromptinstance can be reused across multiple context blocks and extended incrementally.