@aws/mynah-ui 4.23.0-beta.2 → 4.23.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helper/serialize-chat.d.ts +12 -0
- package/dist/main.d.ts +6 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/docs/USAGE.md +20 -0
- package/package.json +1 -1
package/docs/USAGE.md
CHANGED
|
@@ -18,6 +18,7 @@ mynahUI.addToUserPrompt(...);
|
|
|
18
18
|
mynahUI.updateLastChatAnswer(...);
|
|
19
19
|
mynahUI.updateChatAnswerWithMessageId(...);
|
|
20
20
|
mynahUI.endMessageStream(...);
|
|
21
|
+
mynahUI.serializeChat(...);
|
|
21
22
|
mynahUI.updateStore(...);
|
|
22
23
|
mynahUI.selectTab(...);
|
|
23
24
|
mynahUI.removeTab(...);
|
|
@@ -390,6 +391,25 @@ Can you end stream for a card you already ended the stream? Basically yes becaus
|
|
|
390
391
|
|
|
391
392
|
---
|
|
392
393
|
|
|
394
|
+
## Serializing a chat (`serializeChat`)
|
|
395
|
+
|
|
396
|
+
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:
|
|
397
|
+
- **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`.
|
|
398
|
+
- **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.
|
|
399
|
+
|
|
400
|
+
The following example shows how serialization could be used to download an export of a tab's chat:
|
|
401
|
+
```typescript
|
|
402
|
+
const serializedChat = mynahUI.serializeChat(tabId, 'markdown')
|
|
403
|
+
const blob = new Blob([serializedChat], { type: 'text/plain' });
|
|
404
|
+
const url = URL.createObjectURL(blob);
|
|
405
|
+
const link = document.createElement('a');
|
|
406
|
+
link.download = 'exported-chat.md';
|
|
407
|
+
link.href = url;
|
|
408
|
+
link.click();
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
393
413
|
## Adding code attachments to prompt field (`addToUserPrompt`)
|
|
394
414
|
|
|
395
415
|
You can add code attachments under the prompt field of the desired tab. When user fills the prompt field and sends it, the attached code block will be appended at the end of the prompt text. It accepts max chars set through **[CONFIG](./CONFIG.md#maxUserInput)** however you don't need to worry about it. MynahUI will automatically crop it depending on the available chars left from the prompt field itself by using a `96` chars of threshold. **So beware that for example if you want 4000 chars exact, you need to give 4096 to the config.**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/mynah-ui",
|
|
3
3
|
"displayName": "AWS Mynah UI",
|
|
4
|
-
"version": "4.23.0-beta.
|
|
4
|
+
"version": "4.23.0-beta.4",
|
|
5
5
|
"description": "AWS Toolkit VSCode and Intellij IDE Extension Mynah UI",
|
|
6
6
|
"publisher": "Amazon Web Services",
|
|
7
7
|
"license": "Apache License 2.0",
|