@aws/mynah-ui
Advanced tools
Comparing version 4.23.0-beta.2 to 4.23.0-beta.3
@@ -122,2 +122,8 @@ /*! | ||
/** | ||
* Serialize all (non-empty) chat messages in a tab into a string | ||
* @param tabId Corresponding tab ID. | ||
* @param format Whether to serialize to markdown or HTML format | ||
*/ | ||
serializeChat: (tabId: string, format: 'markdown' | 'html') => string; | ||
/** | ||
* Converts a card to an ANSWER if it is an ANSWER_STREAM | ||
@@ -124,0 +130,0 @@ * @param tabId Corresponding tab ID. |
@@ -21,2 +21,3 @@ # How to use MynahUI | ||
mynahUI.endMessageStream(...); | ||
mynahUI.serializeChat(...); | ||
mynahUI.updateStore(...); | ||
@@ -394,2 +395,21 @@ mynahUI.selectTab(...); | ||
## Serializing a chat (`serializeChat`) | ||
You can serialize an entire chat from a specific tab using this function. Only the card bodies will be included, meaning that buttons and other interactable components are left out. There are two output options for the serialization: | ||
- **Markdown:** get all the bodies from chat items in markdown format so that it serves as the contents of a valid `.md` file. Each card body is separated by `\n\n---\n\n`. | ||
- **HTML:** get a string which serves as the contents of a valid `.html` file. It consists of a centered chat container, containing all the chat item bodies in cards. All the relevant stylesheets from MynahUI are included in the `<style>` section of the string. | ||
The following example shows how serialization could be used to download an export of a tab's chat: | ||
```typescript | ||
const serializedChat = mynahUI.serializeChat(tabId, 'markdown') | ||
const blob = new Blob([serializedChat], { type: 'text/plain' }); | ||
const url = URL.createObjectURL(blob); | ||
const link = document.createElement('a'); | ||
link.download = 'exported-chat.md'; | ||
link.href = url; | ||
link.click(); | ||
``` | ||
--- | ||
## Adding code attachments to prompt field (`addToUserPrompt`) | ||
@@ -396,0 +416,0 @@ |
{ | ||
"name": "@aws/mynah-ui", | ||
"displayName": "AWS Mynah UI", | ||
"version": "4.23.0-beta.2", | ||
"version": "4.23.0-beta.3", | ||
"description": "AWS Toolkit VSCode and Intellij IDE Extension Mynah UI", | ||
@@ -6,0 +6,0 @@ "publisher": "Amazon Web Services", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
28420130
208
9386