Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions client-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to **Pipecat Client JS** will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### 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.

## [1.4.1]

### Added
Expand Down
20 changes: 19 additions & 1 deletion client-js/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import packageJson from "../package.json";
import {
BotLLMSearchResponseData,
BotLLMTextData,
BotOutputData,
BotReadyData,
BotTTSTextData,
ClientMessageData,
Expand Down Expand Up @@ -101,6 +102,7 @@ export type RTVIEventCallbacks = Partial<{
onUserStartedSpeaking: () => void;
onUserStoppedSpeaking: () => void;
onUserTranscript: (data: TranscriptData) => void;
onBotOutput: (data: BotOutputData) => void;
onBotTranscript: (data: BotLLMTextData) => void;

onBotLlmText: (data: BotLLMTextData) => void;
Expand Down Expand Up @@ -158,6 +160,8 @@ export class PipecatClient extends RTVIEventEmitter {
protected _functionCallCallbacks: Record<string, FunctionCallCallback> = {};
protected _abortController: AbortController | undefined;

private _botTranscriptionWarned = false;

constructor(options: PipecatClientOptions) {
super();

Expand Down Expand Up @@ -300,7 +304,17 @@ export class PipecatClient extends RTVIEventEmitter {
options?.callbacks?.onUserTranscript?.(data);
this.emit(RTVIEvent.UserTranscript, data);
},
onBotOutput: (data) => {
options?.callbacks?.onBotOutput?.(data);
this.emit(RTVIEvent.BotOutput, data);
},
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."

);
this._botTranscriptionWarned = true;
}
options?.callbacks?.onBotTranscript?.(text);
this.emit(RTVIEvent.BotTranscript, text);
},
Expand Down Expand Up @@ -369,7 +383,7 @@ export class PipecatClient extends RTVIEventEmitter {
@transportAlreadyStarted
public async startBot(startBotParams: APIRequest): Promise<unknown> {
this._transport.state = "authenticating";
this._transport.startBotParams = startBotParams
this._transport.startBotParams = startBotParams;
this._abortController = new AbortController();
let response: unknown;
try {
Expand Down Expand Up @@ -701,6 +715,10 @@ export class PipecatClient extends RTVIEventEmitter {
this._options.callbacks?.onUserTranscript?.(TranscriptData);
break;
}
case RTVIMessageType.BOT_OUTPUT: {
this._options.callbacks?.onBotOutput?.(ev.data as BotOutputData);
break;
}
case RTVIMessageType.BOT_TRANSCRIPTION: {
this._options.callbacks?.onBotTranscript?.(ev.data as BotLLMTextData);
break;
Expand Down
4 changes: 4 additions & 0 deletions client-js/rtvi/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DeviceError } from "./errors";
import {
BotLLMSearchResponseData,
BotLLMTextData,
BotOutputData,
BotReadyData,
BotTTSTextData,
LLMFunctionCallData,
Expand Down Expand Up @@ -46,6 +47,8 @@ export enum RTVIEvent {

// stt events
UserTranscript = "userTranscript",
BotOutput = "botOutput",
// DEPRECATED
BotTranscript = "botTranscript",

// llm events
Expand Down Expand Up @@ -117,6 +120,7 @@ export type RTVIEvents = Partial<{

// stt events
userTranscript: (data: TranscriptData) => void;
botOutput: (data: BotOutputData) => void;
botTranscript: (data: BotLLMTextData) => void;

// llm events
Expand Down
8 changes: 8 additions & 0 deletions client-js/rtvi/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export enum RTVIMessageType {

/** Transcription Messages */
USER_TRANSCRIPTION = "user-transcription", // Local user speech to text transcription (partials and finals)
BOT_OUTPUT = "bot-output", // A best effort aggregation of all bot output along with metadata like if it's spoken
// DEPRECATED
BOT_TRANSCRIPTION = "bot-transcription", // Bot full text transcription (sentence aggregated)
USER_STARTED_SPEAKING = "user-started-speaking", // User started speaking
USER_STOPPED_SPEAKING = "user-stopped-speaking", // User stopped speaking
Expand Down Expand Up @@ -119,6 +121,12 @@ export type TranscriptData = {
user_id: string;
};

export type BotOutputData = {
text: string;
spoken: boolean;
aggregated_by?: "word" | "sentence" | string;
Comment on lines +124 to +127
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.

};

export type BotLLMTextData = {
text: string;
};
Expand Down