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

Support chat transcription forwarding #99

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

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Oct 7, 2024

No description provided.

Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: ed47c1c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-openai Patch
livekit-agents-examples Patch

Not sure what this means? Click here to learn what changesets are.

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

@lukasIO lukasIO changed the title WIP: support chat transcription forwarding Support chat transcription forwarding Oct 14, 2024
@lukasIO lukasIO marked this pull request as ready for review October 14, 2024 14:21
}
}

protected async sendChatMessage() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

one issue with this approach is that we'll eventually run into datapacket size limit restrictions with very long messages.
should we segment them in the sdk or use a tokenizer of sorts after a certain length?

Copy link
Contributor

@bcherry bcherry Oct 15, 2024

Choose a reason for hiding this comment

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

IMO it would be fine to simply truncate at 15KB or up to 63KB and log a warning, for now. If we do decide to split into multiple messages things get messy, esp with edits. and tokenization-aware splitting may be tricky too in UTF-8 where characters have variable bytesizes...

@nbsp
Copy link
Member

nbsp commented Oct 14, 2024

can you mark the changeset as minor and anchor this to v0.4.0 instead of main?

}
}

protected async sendChatMessage() {
Copy link
Contributor

@bcherry bcherry Oct 15, 2024

Choose a reason for hiding this comment

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

IMO it would be fine to simply truncate at 15KB or up to 63KB and log a warning, for now. If we do decide to split into multiple messages things get messy, esp with edits. and tokenization-aware splitting may be tricky too in UTF-8 where characters have variable bytesizes...

case TranscriptionType.TRANSCRIPTION:
case TranscriptionType.CHAT_AND_TRANSCRIPTION:
await this.publishTranscription(false);
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

this switch looks wrong to me - won't chat only still fall through to transcription? a switch doesn't seem like the right conditional type to use for a-b-or-both behavior

}
}

export class ChatAndTranscriptionForwarder extends BasicTranscriptionForwarder {
Copy link
Contributor

Choose a reason for hiding this comment

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

implementing this as a subclass feels unnecessarily brittle and hard to follow - it's already slightly tricky code.

@@ -14,101 +15,108 @@ export interface TranscriptionForwarder {
currentCharacterIndex: number;
}

export enum TranscriptionType {
Copy link
Contributor

Choose a reason for hiding this comment

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

ForwardingType would be a clearer name. I'd also consider making the options Transcription and Chat and the setting an array, rather than a third enum value. then you can simplify the forwarding checks in the loop to

if (forwarding_types.contains('transcription')) {
...
}
if (forwarding_types.contains('chat')) {
...
}

@nbsp nbsp mentioned this pull request Nov 7, 2024
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.

3 participants