Skip to content

Conversation

@mattieruth
Copy link
Contributor

…ks and deprecating bot-transcription callbacks

Resolves #158

…ks and deprecating bot-transcription callbacks

Resolves #158
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for a new bot-output event that provides a unified interface for bot output with metadata about whether text is spoken. It deprecates the existing bot-transcription callbacks in favor of this new event type.

Key Changes

  • Introduces BOT_OUTPUT message type and BotOutputData type with text, spoken, and optional aggregation metadata
  • Adds corresponding botOutput event handlers and callbacks throughout the client
  • Implements deprecation warning for bot-transcription callbacks

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
client-js/rtvi/messages.ts Defines new BOT_OUTPUT message type and BotOutputData type structure
client-js/rtvi/events.ts Adds BotOutput event and callback type definitions
client-js/client/client.ts Implements bot-output event handling and deprecation warning logic
client-js/CHANGELOG.md Documents the addition and deprecation in release notes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +124 to +127
export type BotOutputData = {
text: string;
spoken: boolean;
aggregated_by?: "word" | "sentence" | string;
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The aggregated_by field allows arbitrary strings which could lead to inconsistent values. Consider using only the union of literal types 'word' | 'sentence' or defining an enum to ensure type safety and prevent typos.

Suggested change
export type BotOutputData = {
text: string;
spoken: boolean;
aggregated_by?: "word" | "sentence" | string;
export enum AggregatedByType {
WORD = "word",
SENTENCE = "sentence",
}
export type BotOutputData = {
text: string;
spoken: boolean;
aggregated_by?: AggregatedByType;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no. the point is that the value can be any string, but adding in the "word" | "sentence" makes it clear that those are sort-of built-in or common values that can be expected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also wonder if we should have an extra field like "type" or "kind." But I’m not sure whether we’ll have that information inside Pipecat.


### Added

- BotOutput
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The changelog entry for BotOutput lacks detail. Include a brief description of what the feature does, such as 'Added BotOutput event providing unified bot output with spoken metadata and aggregation information'.

Suggested change
- BotOutput
- Added BotOutput event providing unified bot output with spoken metadata and aggregation information.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with Copilot on this one. 😅
But I guess you just left it here for now so you’d remember to describe it later.


### Deprecated

- BotTranscription
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The deprecation notice should mention the replacement: 'Deprecated BotTranscription in favor of BotOutput event'.

Suggested change
- BotTranscription
- Deprecated `BotTranscription` in favor of the new `BotOutput` event.

Copilot uses AI. Check for mistakes.
onBotTranscript: (text) => {
if (!this._botTranscriptionWarned) {
logger.warn(
"[Pipecat Client] Bot transcription is deprecated. Please use the onBotOutput instead."
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
"[Pipecat Client] Bot transcription is deprecated. Please use the onBotOutput instead."
"[Pipecat Client] onBotTranscript is deprecated. Please use the onBotOutput instead."

Copy link
Collaborator

@filipi87 filipi87 left a comment

Choose a reason for hiding this comment

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

Nice improvement. 🚀

I added a comment about some possible extra fields, but I believe that even if we decide they’re worth adding, it can be a follow up improvement in the future.

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.

Add support for retrieving the effective output of the bot

4 participants