Skip to content

Jinja Template#217

Merged
sadrasabouri merged 21 commits into
devfrom
jinja
Jun 5, 2026
Merged

Jinja Template#217
sadrasabouri merged 21 commits into
devfrom
jinja

Conversation

@sepandhaghighi

Copy link
Copy Markdown
Member

Reference Issues/PRs

What does this implement/fix? Explain your changes

  • PromptTemplate class update_engine method added
  • PromptTemplate class engine property added
  • engine parameter added to PromptTemplate class
  • README.md updated
  • Test system modified

Any other comments?

@sepandhaghighi sepandhaghighi self-assigned this Jun 3, 2026
@sepandhaghighi sepandhaghighi added the enhancement New feature or request label Jun 3, 2026
@sepandhaghighi sepandhaghighi added this to the memor v1.2 milestone Jun 3, 2026
@codacy-production

codacy-production Bot commented Jun 3, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 20 complexity · 0 duplication

Metric Results
Complexity 20
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov-commenter

codecov-commenter commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.51%. Comparing base (46c00a8) to head (5657745).

Files with missing lines Patch % Lines
memor/template.py 83.34% 1 Missing and 3 partials ⚠️
memor/functions.py 66.67% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #217      +/-   ##
==========================================
- Coverage   98.80%   98.51%   -0.28%     
==========================================
  Files          12       12              
  Lines        1907     1939      +32     
  Branches      184      189       +5     
==========================================
+ Hits         1884     1910      +26     
- Misses          5        7       +2     
- Partials       18       22       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sepandhaghighi sepandhaghighi marked this pull request as ready for review June 4, 2026 22:26
@sepandhaghighi

Copy link
Copy Markdown
Member Author

@sadrasabouri

Two notices:

  1. Regarding testing and coverage, future pull requests should incorporate more comprehensive tests to enhance test coverage and accuracy.

  2. Concerning B701, PromptTemplate is intended for generating text or prompts, not for rendering HTML or XML. Autoescaping would alter the contents of the prompt and lead to unforeseen output.

@sadrasabouri sadrasabouri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great job! I have minor suggestions on tests.

Comment thread tests/test_prompt_template.py
Comment thread tests/test_prompt_template.py Outdated
Comment on lines +521 to +540
def test_render_jinja8():
template = PromptTemplate(
content="{{ greeting }}, {{ name }}!",
custom_map={"greeting": "Hello"},
engine=TemplateEngine.JINJA,
)
assert template.render(
{"name": "Bob"}
) == "Hello, Bob!"


def test_render_jinja9():
template = PromptTemplate(
content="{{ greeting }}, {{ name }}!",
custom_map={"greeting": "Hello"},
engine=TemplateEngine.JINJA,
)
assert template.render(
{"greeting": "Hi", "name": "Bob"}
) == "Hi, Bob!"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these two tests cover the same thing as the first two tests (language). I suggest removing them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed in b323c3f

Comment thread tests/test_prompt_template.py Outdated
Comment on lines +553 to +559
def test_render_jinja11():
template = PromptTemplate(
content="{{ missing_variable }}",
engine=TemplateEngine.JINJA,
)
with pytest.raises(MemorRenderError, match="Template and context are incompatible."):
template.render({})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same for this. I suggest removing this test too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This one is a bit different

@sadrasabouri sadrasabouri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me now!

@sadrasabouri sadrasabouri merged commit e8d39c8 into dev Jun 5, 2026
25 checks passed
@sadrasabouri sadrasabouri deleted the jinja branch June 5, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants