StreamingResponse class
A helper class for streaming responses to the client.
Remarks
This class is used to send a series of updates to the client in a single response. The expected sequence of calls is:
queueInformativeUpdate(), queueTextChunk(), queueTextChunk(), ..., endStream().
Once endStream() is called, the stream is considered ended and no further updates can be sent.
Constructors
| Streaming |
Creates a new StreamingResponse instance. |
Properties
| citations | Gets the citations of the current response. |
| delay |
Gets the delay in milliseconds between chunks. |
| is |
Gets whether the channel supports streaming. |
| stream |
Gets the stream ID of the current response. |
| updates |
Gets the number of updates sent for the stream. |
Methods
| end |
Ends the stream by sending the final message to the client. |
| get |
Returns the most recently streamed message. |
| queue |
Queues an informative update to be sent to the client. |
| queue |
Queues a chunk of partial message text to be sent to the client |
| reset() | Resets the streaming response to its initial state. If the stream is still running, this will wait for completion. |
| set |
Sets the attachments to attach to the final chunk. |
| set |
Sets the citations for the full message. |
| set |
Sets the delay in milliseconds between chunks. |
| set |
Sets the Feedback Loop in Teams that allows a user to
give thumbs up or down to a response.
Default is |
| set |
Sets the type of UI to use for the feedback loop. |
| set |
Set Activity that will be (optionally) used for the final streaming message. |
| set |
Sets the the Generated by AI label in Teams
Default is |
| set |
Sets the sensitivity label to attach to the final chunk. |
Constructor Details
StreamingResponse(TurnContext)
Creates a new StreamingResponse instance.
new StreamingResponse(context: TurnContext)
Parameters
- context
- TurnContext
Context for the current turn of conversation with the user.
Property Details
citations
Gets the citations of the current response.
undefined | ClientCitation[] citations
Property Value
undefined | ClientCitation[]
delayInMs
Gets the delay in milliseconds between chunks.
number delayInMs
Property Value
number
isStreamingChannel
Gets whether the channel supports streaming.
boolean isStreamingChannel
Property Value
boolean
streamId
Gets the stream ID of the current response.
undefined | string streamId
Property Value
undefined | string
- The stream ID of the current response.
updatesSent
Gets the number of updates sent for the stream.
number updatesSent
Property Value
number
- The number of updates sent for the stream.
Method Details
endStream()
Ends the stream by sending the final message to the client.
function endStream(): Promise<StreamingResponseResult>
Returns
Promise<StreamingResponseResult>
- StreamingResponseResult with the result of the streaming response.
getMessage()
Returns the most recently streamed message.
function getMessage(): string
Returns
string
The streamed message.
queueInformativeUpdate(string)
Queues an informative update to be sent to the client.
function queueInformativeUpdate(text: string)
Parameters
- text
-
string
Text of the update to send.
queueTextChunk(string, Citation[])
Queues a chunk of partial message text to be sent to the client
function queueTextChunk(text: string, citations?: Citation[])
Parameters
- text
-
string
Partial text of the message to send.
- citations
-
Citation[]
Citations to be included in the message.
Remarks
The text we be sent as quickly as possible to the client. Chunks may be combined before delivery to the client.
reset()
Resets the streaming response to its initial state. If the stream is still running, this will wait for completion.
function reset(): Promise<void>
Returns
Promise<void>
setAttachments(Attachment[])
Sets the attachments to attach to the final chunk.
function setAttachments(attachments: Attachment[])
Parameters
- attachments
List of attachments.
setCitations(Citation[])
Sets the citations for the full message.
function setCitations(citations: Citation[])
Parameters
- citations
-
Citation[]
Citations to be included in the message.
setDelayInMs(number)
Sets the delay in milliseconds between chunks.
function setDelayInMs(delayInMs: number)
Parameters
- delayInMs
-
number
The delay in milliseconds.
setFeedbackLoop(boolean)
Sets the Feedback Loop in Teams that allows a user to
give thumbs up or down to a response.
Default is false.
function setFeedbackLoop(enableFeedbackLoop: boolean)
Parameters
- enableFeedbackLoop
-
boolean
If true, the feedback loop is enabled.
setFeedbackLoopType("default" | "custom")
Sets the type of UI to use for the feedback loop.
function setFeedbackLoopType(feedbackLoopType: "default" | "custom")
Parameters
- feedbackLoopType
-
"default" | "custom"
The type of the feedback loop.
setFinalMessage(Activity)
Set Activity that will be (optionally) used for the final streaming message.
function setFinalMessage(activity: Activity)
Parameters
- activity
- Activity
setGeneratedByAILabel(boolean)
Sets the the Generated by AI label in Teams
Default is false.
function setGeneratedByAILabel(enableGeneratedByAILabel: boolean)
Parameters
- enableGeneratedByAILabel
-
boolean
If true, the label is added.
setSensitivityLabel(SensitivityUsageInfo)
Sets the sensitivity label to attach to the final chunk.
function setSensitivityLabel(sensitivityLabel: SensitivityUsageInfo)
Parameters
- sensitivityLabel
- SensitivityUsageInfo
The sensitivty label.