-
Notifications
You must be signed in to change notification settings - Fork 3.7k
workflows: spell the value back once the caller refuses a confirmation #6990
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c9d305a
workflows: a read-back that spells the value once a confirmation is r…
u9g 4bd1989
workflows: spell the value back once the caller refuses a confirmation
u9g df13bf6
workflows: inline the read-back escalation into each task
u9g 8232cb4
workflows: pre-space name and street confirmation spelling
u9g b7f6352
workflows: single-space the spelled name and street read-backs
u9g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from types import SimpleNamespace | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
|
|
||
| from livekit.agents import beta | ||
|
|
||
| pytestmark = pytest.mark.unit | ||
|
|
||
|
|
||
| def _audio_ctx() -> Any: | ||
| return SimpleNamespace( | ||
| speech_handle=SimpleNamespace(input_details=SimpleNamespace(modality="audio")) | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_email_is_spelled_once_a_confirmation_is_refused() -> None: | ||
| task = beta.workflows.GetEmailTask() | ||
| ctx = _audio_ctx() | ||
|
|
||
| first = await task._update_email_impl("shayne.cole@gmail.com", ctx) | ||
| second = await task._update_email_impl("shayne.cole@gmail.com", ctx) | ||
|
|
||
| assert first is not None and second is not None | ||
| assert first != second | ||
| assert " ".join("shayne.cole@gmail.com") in second | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize( | ||
| ("first_name", "last_name"), | ||
| [("Shayne", "Cole"), ("Anne-Marie", "O'Neill"), ("Ana", "García")], | ||
| ) | ||
| async def test_name_is_spelled_on_subsequent_updates(first_name: str, last_name: str) -> None: | ||
| task = beta.workflows.GetNameTask(first_name=True, last_name=True) | ||
| ctx = _audio_ctx() | ||
|
|
||
| first = await task._update_name_impl(ctx, first_name=first_name, last_name=last_name) | ||
| second = await task._update_name_impl(ctx, first_name=first_name, last_name=last_name) | ||
| third = await task._update_name_impl(ctx, first_name=first_name, last_name=last_name) | ||
|
|
||
| assert first is not None and second is not None | ||
| assert first != second | ||
| spelled = " ".join(f"{first_name}{last_name}") | ||
| assert spelled not in first | ||
| assert spelled in second | ||
| assert " " not in second | ||
| assert third == second | ||
| assert task._first_name == first_name | ||
| assert task._last_name == last_name | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_name_with_verify_spelling_is_spelled_from_the_start() -> None: | ||
| task = beta.workflows.GetNameTask(first_name=True, verify_spelling=True) | ||
| ctx = _audio_ctx() | ||
|
|
||
| first = await task._update_name_impl(ctx, first_name="Shayne") | ||
| second = await task._update_name_impl(ctx, first_name="Shayne") | ||
|
|
||
| assert first == second | ||
| assert first is not None | ||
| assert "S h a y n e" in first | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_phone_is_read_digit_by_digit_once_a_confirmation_is_refused() -> None: | ||
| task = beta.workflows.GetPhoneNumberTask() | ||
| ctx = _audio_ctx() | ||
|
|
||
| first = await task._update_phone_number_impl("415-555-0626", ctx) | ||
| second = await task._update_phone_number_impl("415-555-0626", ctx) | ||
|
|
||
| assert first is not None and second is not None | ||
| assert first != second | ||
| assert " ".join("4155550626") in second | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize( | ||
| ("street", "unit", "locality", "country"), | ||
| [ | ||
| ("1 Main St", "", "Springfield", "US"), | ||
| ("88 Harbor Lane", "Apartment 3", "Portland Oregon 97209", "United States"), | ||
| ("5 Rue de l’Ancienne Comédie", "App C4", "75006 Paris", "France"), | ||
| ], | ||
| ) | ||
| async def test_address_is_spelled_on_subsequent_updates( | ||
| street: str, unit: str, locality: str, country: str | ||
| ) -> None: | ||
| task = beta.workflows.GetAddressTask() | ||
| ctx = _audio_ctx() | ||
|
|
||
| first = await task._update_address_impl(street, unit, locality, country, ctx) | ||
| second = await task._update_address_impl(street, unit, locality, country, ctx) | ||
| third = await task._update_address_impl(street, unit, locality, country, ctx) | ||
|
|
||
| assert first is not None and second is not None | ||
| assert first != second | ||
| spelled = " ".join(street.replace(" ", "")) | ||
| assert spelled not in first | ||
| assert spelled in second | ||
| assert " " not in second | ||
| assert third == second | ||
| fields = [street, unit, locality, country] if unit else [street, locality, country] | ||
| assert task._current_address == " ".join(fields) | ||
| assert str([spelled, *fields[1:]]) in second | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_dob_is_read_part_by_part_once_a_confirmation_is_refused() -> None: | ||
| task = beta.workflows.GetDOBTask() | ||
| ctx = _audio_ctx() | ||
|
|
||
| first = await task._update_dob_impl(1990, 5, 17, ctx) | ||
| second = await task._update_dob_impl(1990, 5, 17, ctx) | ||
|
|
||
| assert first is not None and second is not None | ||
| assert first != second |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Name boundaries vanish during spelling
Names containing spaces inside or between parts lose every boundary through
replace.Ann A BellandAnna Bellproduce the same character sequence, so callers cannot identify the stored name. Street-address boundaries disappear throughreplacetoo.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.