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 out-of-band responses + controlled response timing #1320

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tinalenguyen
Copy link
Contributor

@tinalenguyen tinalenguyen commented Dec 31, 2024

I recently came across new additions that OpenAI developed and would love for them to be included in Livekit!

I worked on out-of-band responses and an extra VAD option where responses are not automatic. I also added an option to turn server VAD off by turn_detection="None" in session.update().

Please let me know your thoughts! :-)

Copy link

changeset-bot bot commented Dec 31, 2024

⚠️ No Changeset found

Latest commit: e8e33a6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -287,9 +288,6 @@ def __init__(
ValueError: If the API key is not provided and cannot be found in environment variables.
"""
super().__init__()
self._capabilities = Capabilities(
Copy link
Member

Choose a reason for hiding this comment

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

We should keep the capabilities property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was that a new addition? I just updated with the differences

Copy link
Member

Choose a reason for hiding this comment

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

Yes it is a new one

@@ -880,7 +938,7 @@ def session_update(
input_audio_format: api_proto.AudioFormat | None = None,
output_audio_format: api_proto.AudioFormat | None = None,
input_audio_transcription: InputTranscriptionOptions | None = None,
turn_detection: ServerVadOptions | None = None,
turn_detection: ServerVadOptions | Literal["None"] | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see this PR was also adding None to the turn_detection.
It has been done inside this PR: #1347

We're still interested to have this out-of-band responses tho! :)

Copy link
Contributor Author

@tinalenguyen tinalenguyen Jan 11, 2025

Choose a reason for hiding this comment

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

I integrated the changes! It should all work now :D

Comment on lines 772 to 794
if instructions is not None:
self._sess._queue_msg(
{
"type": "response.create",
"response": {
"conversation": conversation,
"metadata": metadata,
"instructions": instructions,
"modalities": modalities,
},
}
)
else:
self._sess._queue_msg(
{
"type": "response.create",
"response": {
"conversation": conversation,
"metadata": metadata,
"modalities": modalities,
},
}
)
Copy link
Member

Choose a reason for hiding this comment

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

Is the reason for this if-else condition the fact that OAI will returns an error if instructions is set to None/null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot but that sounds about right, it works without it now though

@tinalenguyen tinalenguyen reopened this Jan 11, 2025
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.

2 participants