llm: omit image collection names in prompt placeholders#916
llm: omit image collection names in prompt placeholders#916matthewYang08 wants to merge 2 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
Greptile SummaryThis PR changes how image collections are rendered in prompt placeholders. The main changes are:
Confidence Score: 4/5This is close, but the dict image collection path should be fixed before merging.
Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
pipelex/core/stuffs/structured_content.py:203-205
**Dict fields stay undiscoverable** The renderer now treats `dict[str, ImageContent]` as an image collection, but the image-field discovery path used by prompt validation still only recognizes list and tuple containers. A structured concept whose only images are in a dict field can render correctly here, but `{{ gallery | with_images }}` is rejected earlier as having no nested images, so this new dict support is unreachable in normal prompt flows.
Reviews (1): Last reviewed commit: "llm: omit image collection names in prom..." | Re-trigger Greptile |
recheck |
| if isinstance(value, dict): | ||
| dict_value = cast("dict[str, Any]", value) | ||
| return bool(dict_value) and all(self._is_image_only_value(item) for item in dict_value.values()) |
There was a problem hiding this comment.
Dict fields stay undiscoverable The renderer now treats
dict[str, ImageContent] as an image collection, but the image-field discovery path used by prompt validation still only recognizes list and tuple containers. A structured concept whose only images are in a dict field can render correctly here, but {{ gallery | with_images }} is rejected earlier as having no nested images, so this new dict support is unreachable in normal prompt flows.
Prompt To Fix With AI
This is a comment left during a code review.
Path: pipelex/core/stuffs/structured_content.py
Line: 203-205
Comment:
**Dict fields stay undiscoverable** The renderer now treats `dict[str, ImageContent]` as an image collection, but the image-field discovery path used by prompt validation still only recognizes list and tuple containers. A structured concept whose only images are in a dict field can render correctly here, but `{{ gallery | with_images }}` is rejected earlier as having no nested images, so this new dict support is unreachable in normal prompt flows.
How can I resolve this? If you propose a fix, please make it concise.|
Closed because it was pointing on main: see #917 |
Summary
This PR addresses #521 by omitting collection names when rendering image collections into prompt placeholders.
What changed
StructuredContent.render_with_images()behavior:page_view) unchanged.with_imagesValidation
pytest tests/unit/pipelex/core/stuffs/test_structured_content_render_with_images.pypytest tests/integration/pipelex/pipes/llm_prompt_inputs/test_prompt_image_extraction.py --disable-inferenceruff checkon changed filespyrighton changed filesRefs #521
Summary by cubic
Updates prompt rendering to omit names for image-only collections (lists, tuples, dicts) and keep labels for single-image fields, reducing noise and aligning with image extraction (addresses #521). Also extends nested image discovery to detect dict-based image collections.
StructuredContent.render_with_images()to hide names for image-only collections; preserve names for mixed dicts and non-collection fields.ListContentvia_is_image_collection_value()and_is_image_only_value().search_for_nested_image_fields()/check_generic_container_for_images(); added tests for dict containers, tuples, nested lists, mixed dicts, and label preservation in prompt extraction.Written for commit c8a3732. Summary will update on new commits. Review in cubic