-
Notifications
You must be signed in to change notification settings - Fork 2.8k
migrate to turn_handling #4502
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
migrate to turn_handling #4502
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f0791a2
add turn_handling
chenghao-mou de1d9e8
fix type issues
chenghao-mou 27d87a0
fix cli audio callback
chenghao-mou e3c98e3
remove unnecessary fix
chenghao-mou 9bb5db3
replace deprecate warning with log warning
chenghao-mou fa39089
fix allow_interruptions assignment
chenghao-mou 636a78c
minor refactor
chenghao-mou 6ecb324
update docs and agent event
chenghao-mou 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
350 changes: 203 additions & 147 deletions
350
...gents/livekit/agents/inference/bargein.py → .../livekit/agents/inference/interruption.py
Large diffs are not rendered by default.
Oops, something went wrong.
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,49 @@ | ||
| import functools | ||
| import inspect | ||
| from collections import defaultdict | ||
| from typing import Any, Callable | ||
|
|
||
| from ..log import logger | ||
| from ..types import NOT_GIVEN | ||
| from .misc import is_given | ||
|
|
||
|
|
||
| def deprecate_params(mapping: dict[str, str]) -> Callable[[Callable[..., Any]], Callable[..., Any]]: | ||
| """ | ||
| Args: | ||
| mapping: {old_param: suggestion} | ||
|
|
||
| Example: | ||
| >>> @deprecate_params({ | ||
| ... "old_param": "Use new_param instead", | ||
| ... }) | ||
| ... def my_function(old_param: NotGivenOr[int] = NOT_GIVEN, new_param: int = 0): | ||
| ... print(old_param) | ||
| >>> my_function(old_param=1) | ||
| WARNING: old_param is deprecated. Use new_param instead | ||
| 1 | ||
| >>> my_function(new_param=1) # no warning | ||
| """ | ||
|
|
||
| def decorator(fn: Callable[..., Any]) -> Callable[..., Any]: | ||
| signature = inspect.signature(fn) | ||
|
|
||
| @functools.wraps(fn) | ||
| def wrapper(*args: Any, **kwargs: Any) -> Any: | ||
| bound = signature.bind_partial(*args, **kwargs) | ||
| by_suggestion: defaultdict[str, list[str]] = defaultdict(list) | ||
| for name, suggestion in mapping.items(): | ||
| if is_given(bound.arguments.get(name, NOT_GIVEN)): | ||
| by_suggestion[suggestion].append(name) | ||
|
|
||
| for suggestion, names in by_suggestion.items(): | ||
| params = ", ".join(names) | ||
| logger.warning( | ||
| f"{params} {'are' if len(names) > 1 else 'is'} deprecated. {suggestion}", | ||
| stacklevel=2, | ||
| ) | ||
| return fn(*args, **kwargs) | ||
|
|
||
| return wrapper | ||
|
|
||
| return decorator |
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
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.
Uh oh!
There was an error while loading. Please reload this page.