Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for NLG change - [ENG 501] #12875

Merged
merged 5 commits into from
Oct 10, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/core/nlg/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,29 @@ async def test_nlg_conditional_response_variations_condition_logging(
"[condition 2] type: slot | name: test_B | value: B" in message
for message in caplog.messages
)


async def test_nlg_response_with_jinja_template():
varunshankar marked this conversation as resolved.
Show resolved Hide resolved
domain = Domain.from_yaml(
f"""
version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
responses:
utter_flow_xyz:
- text: "Do you want to update the
{{{{ context.corrected_slots.keys()|join(', ') }}}}?"
metadata:
rephrase: true
template: jinja
"""
)
t = TemplatedNaturalLanguageGenerator(domain.responses)
r = t.generate_from_slots(
"utter_flow_xyz",
{"tm": "50"},
{
"frame_id": "XYYZABCD",
"corrected_slots": {"tm": "100"},
},
"",
)
assert r.get("text") == "Do you want to update the tm?"
Loading