-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Chat Streaming behavior (#12)
update Chat Headless to expose a `streamNextMessage` function that internally will invoke Chat Core `streamNextMessage`. `ConversationState.Messages` state will get updated by appending the token to `text` field from `streamToken` event every time there's a new `streamToken` event. Notes are updated at the start of the stream from `startTokenStream` event. And finally, conversationId and message (for the timestamp) is updated from `endStream` event. Updated test app to use both non-stream and stream method. Added more jest tests. J=CLIP-152 TEST=manual&auto see that jest tests passed see that test app stream response to page as expected
- Loading branch information
Showing
15 changed files
with
451 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @yext/clippy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
REACT_APP_BOT_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/chat-headless/docs/chat-headless.chatheadless.streamnextmessage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatHeadless](./chat-headless.chatheadless.md) > [streamNextMessage](./chat-headless.chatheadless.streamnextmessage.md) | ||
|
||
## ChatHeadless.streamNextMessage() method | ||
|
||
Performs a Chat Stream API request for the next message generated by chat bot using the conversation state (e.g. message history and notes). The new message's "text" field is continously updated as tokens from the stream are consumed. Remaining conversation state are updated once the final event from the stream is recieved. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
streamNextMessage(text?: string, source?: MessageSource): Promise<MessageResponse>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| text | string | _(Optional)_ the text of the next message | | ||
| source | MessageSource | _(Optional)_ the source of the message | | ||
|
||
**Returns:** | ||
|
||
Promise<MessageResponse> | ||
|
||
a Promise of the full response from the Chat Stream API | ||
|
||
## Remarks | ||
|
||
If rejected, an Error is returned. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.