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

[DRAFT] Add bot message streaming response events #31299

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"engines": {
"node": ">=18.0.0"
"node": ">=20.0.0"
emlynmac marked this conversation as resolved.
Show resolved Hide resolved
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-chat/",
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { ChatMessageDeletedEvent } from '@azure/communication-signaling';
import { ChatMessageEditedEvent } from '@azure/communication-signaling';
import { ChatMessageReceivedEvent } from '@azure/communication-signaling';
import { ChatMessageReceivedEvent as ChatMessageReceivedEvent_2 } from '@azure/communication-signaling';
import { ChatThreadCreatedEvent } from '@azure/communication-signaling';
import { ChatThreadDeletedEvent } from '@azure/communication-signaling';
import { ChatThreadPropertiesUpdatedEvent } from '@azure/communication-signaling';
Expand Down Expand Up @@ -94,7 +94,7 @@ export interface ChatError {
}

// @public (undocumented)
export type ChatEventId = "chatMessageReceived" | "chatMessageEdited" | "chatMessageDeleted" | "typingIndicatorReceived" | "readReceiptReceived" | "chatThreadCreated" | "chatThreadDeleted" | "chatThreadPropertiesUpdated" | "participantsAdded" | "participantsRemoved" | "realTimeNotificationConnected" | "realTimeNotificationDisconnected";
export type ChatEventId = "chatMessageReceived" | "chatMessageEdited" | "chatMessageDeleted" | "typingIndicatorReceived" | "readReceiptReceived" | "chatThreadCreated" | "chatThreadDeleted" | "chatThreadPropertiesUpdated" | "participantsAdded" | "participantsRemoved" | "streamingChatMessageStarted" | "streamingChatMessageChunkReceived" | "realTimeNotificationConnected" | "realTimeNotificationDisconnected";

// @public
export interface ChatMessage {
Expand Down Expand Up @@ -131,7 +131,10 @@ export interface ChatMessageReadReceipt {
sender: CommunicationIdentifierKind;
}

export { ChatMessageReceivedEvent }
// @public (undocumented)
export interface ChatMessageReceivedEvent extends ChatMessageReceivedEvent_2 {
streamingMetadata?: StreamingMessageMetadata;
}

// @public
export type ChatMessageType = "text" | "html" | "topicUpdated" | "participantAdded" | "participantRemoved";
Expand Down Expand Up @@ -298,6 +301,30 @@ export interface SendTypingNotificationOptions extends OperationOptions {
senderDisplayName?: string;
}

// @public (undocumented)
export type StreamEndReason = "completed" | "expired" | "canceled";

// @public (undocumented)
export interface StreamingChatMessageChunkReceivedEvent extends ChatMessageEditedEvent {
}

// @public (undocumented)
export interface StreamingChatMessageStartEvent extends ChatMessageReceivedEvent {
}

// @public (undocumented)
export type StreamingContentType = "start" | "informative" | "streaming" | "final";

// @public (undocumented)
export interface StreamingMessageMetadata {
// (undocumented)
streamEndReason?: StreamEndReason;
// (undocumented)
streamingContentType?: StreamingContentType;
// (undocumented)
streamingSequenceNumber?: number;
}

export { TypingIndicatorReceivedEvent }

// @public
Expand Down
8 changes: 8 additions & 0 deletions sdk/communication/communication-chat/src/chatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,5 +510,13 @@ export class ChatClient {
this.signalingClient.on("participantsRemoved", (payload) => {
this.emitter.emit("participantsRemoved", payload);
});

// this.signalingClient.on("streamingChatMessageStarted", (payload) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why are these commented?

Copy link
Member

Choose a reason for hiding this comment

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

ah, the PR waits on signaling and is work in progress

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - this PR will not be merged; it's just to highlight the changes coming from the underlying signaling.

// this.emitter.emit("streamingChatMessageStarted", payload);
// });

// this.signalingClient.on("streamingChatMessageChunkReceived", (payload) => {
// this.emitter.emit("streamingChatMessageCompleted", payload);
// });
}
}
26 changes: 25 additions & 1 deletion sdk/communication/communication-chat/src/models/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,36 @@
import {
ChatMessageDeletedEvent,
ChatMessageEditedEvent,
ChatMessageReceivedEvent,
ChatMessageReceivedEvent as OldSignalingMessageReceivedEvent,
ChatThreadCreatedEvent,
ChatThreadDeletedEvent,
ChatThreadPropertiesUpdatedEvent,
ParticipantsAddedEvent,
ParticipantsRemovedEvent,
ReadReceiptReceivedEvent,
// StreamingChatMessageChunkReceivedEvent, // TODO: from signaling once package available
// StreamingChatMessageStartEvent, // rush local packages broken
// StreamingMessageMetadata, //
TypingIndicatorReceivedEvent,
} from "@azure/communication-signaling";

// TODO: Remove these once the signaling package is available
export type StreamingContentType = "start" | "informative" | "streaming" | "final";
export type StreamEndReason = "completed" | "expired" | "canceled";
export interface StreamingMessageMetadata {
streamingContentType?: StreamingContentType;
streamingSequenceNumber?: number; // Only present on informative or streaming type messages
streamEndReason?: StreamEndReason; // Only present on final type messages
}
interface ChatMessageReceivedEvent extends OldSignalingMessageReceivedEvent {
/**
* If a streaming message, details about the streaming message.
*/
streamingMetadata?: StreamingMessageMetadata;
}
interface StreamingChatMessageStartEvent extends ChatMessageReceivedEvent { }
interface StreamingChatMessageChunkReceivedEvent extends ChatMessageEditedEvent { }

type ChatEventId =
| "chatMessageReceived"
| "chatMessageEdited"
Expand All @@ -25,6 +45,8 @@ type ChatEventId =
| "chatThreadPropertiesUpdated"
| "participantsAdded"
| "participantsRemoved"
| "streamingChatMessageStarted"
| "streamingChatMessageChunkReceived"
| "realTimeNotificationConnected"
| "realTimeNotificationDisconnected";

Expand All @@ -40,4 +62,6 @@ export {
ChatThreadPropertiesUpdatedEvent,
ParticipantsAddedEvent,
ParticipantsRemovedEvent,
StreamingChatMessageChunkReceivedEvent,
StreamingChatMessageStartEvent,
};
Loading