Validate base64 and render outside Prompt with-blocks #35
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.