Skip to content

Conversation

@shreyashankar
Copy link
Collaborator

Gracefully handle non-Jinja prompts in DocETL operations by warning users and automatically appending document statements.

Previously, DocETL operations would fail early if a prompt did not contain Jinja syntax. This change provides a rich console warning and asks for user confirmation. If confirmed, the system automatically appends Here is the document: {{ input }} (or {{ inputs }} for reduce, {{ input1 }}/{{ input2 }} for comparison, {{ left }}/{{ right }} for equijoin) to the prompt during execution, allowing operations to proceed without requiring users to explicitly add Jinja templating for simple cases.


Open in Cursor Open in Web

This commit introduces a confirmation step for prompts that do not contain Jinja2 syntax. It also modifies strict_render to automatically append document context when Jinja syntax is absent.

Co-authored-by: ss.shankar505 <[email protected]>
@cursor
Copy link

cursor bot commented Nov 12, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@shreyashankar
Copy link
Collaborator Author

@cursor fix the CI error.

@cursor
Copy link

cursor bot commented Nov 22, 2025

Taking a look!

Open in Cursor Open in Web

@shreyashankar shreyashankar marked this pull request as ready for review November 22, 2025 20:05
@shreyashankar
Copy link
Collaborator Author

@cursor also why is has_jinja_syntax defined twice? We shouldn't be duplicating logic everywhere.

@cursor
Copy link

cursor bot commented Nov 22, 2025

Summary

I've successfully fixed both the CI error and the code duplication issue:

1. Fixed Circular Import

The test was failing with ImportError: cannot import name 'DOCETL_CONSOLE' from partially initialized module 'docetl.console'. This was caused by a circular import between docetl/console.py and docetl/utils.py. I fixed it by moving the import of DOCETL_CONSOLE inside the prompt_user_for_non_jinja_confirmation function instead of at the module level.

2. Removed Duplicate has_jinja_syntax Function

As you noted, has_jinja_syntax was defined in two places:

  • docetl/utils.py (line 83)
  • docetl/operations/utils/validation.py (line 14)

I removed the duplicate from validation.py and added an import from docetl.utils instead, so there's now a single source of truth for this function.

3. Fixed strict_render AttributeError

The strict_render function in validation.py was trying to access template.source on Jinja2 Template objects, which doesn't exist. I simplified the logic to only process string templates for the non-Jinja syntax check and leave Template objects as-is.

All 104 basic tests now pass successfully! ✅


Open in Cursor Open in Web

Learn more about Cursor Agents

@cursor
Copy link

cursor bot commented Nov 22, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@shreyashankar shreyashankar merged commit 7cca6f5 into main Nov 22, 2025
4 checks passed
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.

3 participants