@patternfly/chatbot 6.4.0-prerelease.2 → 6.4.0-prerelease.21
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/cjs/Chatbot/Chatbot.js +1 -7
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +15 -9
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +40 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.js +25 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +22 -0
- package/dist/cjs/ChatbotHeader/index.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/index.js +1 -0
- package/dist/cjs/DeepThinking/DeepThinking.d.ts +18 -0
- package/dist/cjs/DeepThinking/DeepThinking.js +18 -0
- package/dist/cjs/DeepThinking/DeepThinking.test.d.ts +1 -0
- package/dist/cjs/DeepThinking/DeepThinking.test.js +48 -0
- package/dist/cjs/DeepThinking/index.d.ts +2 -0
- package/dist/cjs/DeepThinking/index.js +23 -0
- package/dist/cjs/FileDetails/FileDetails.d.ts +22 -3
- package/dist/cjs/FileDetails/FileDetails.js +27 -912
- package/dist/cjs/FileDetails/FileDetails.test.js +16 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.d.ts +8 -2
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.js +14 -2
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +19 -1
- package/dist/cjs/FilePreview/FilePreview.d.ts +26 -0
- package/dist/cjs/FilePreview/FilePreview.js +26 -0
- package/dist/cjs/FilePreview/FilePreview.test.d.ts +1 -0
- package/dist/cjs/FilePreview/FilePreview.test.js +97 -0
- package/dist/cjs/FilePreview/index.d.ts +2 -0
- package/dist/cjs/FilePreview/index.js +23 -0
- package/dist/cjs/ImagePreview/ImagePreview.d.ts +53 -0
- package/dist/cjs/ImagePreview/ImagePreview.js +47 -0
- package/dist/cjs/ImagePreview/ImagePreview.test.d.ts +1 -0
- package/dist/cjs/ImagePreview/ImagePreview.test.js +225 -0
- package/dist/cjs/ImagePreview/index.d.ts +2 -0
- package/dist/cjs/ImagePreview/index.js +23 -0
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +3 -3
- package/dist/cjs/Message/LinkMessage/LinkMessage.d.ts +2 -1
- package/dist/cjs/Message/LinkMessage/LinkMessage.js +7 -3
- package/dist/cjs/Message/ListMessage/ListItemMessage.d.ts +1 -1
- package/dist/cjs/Message/ListMessage/ListItemMessage.js +16 -1
- package/dist/cjs/Message/Message.d.ts +15 -0
- package/dist/cjs/Message/Message.js +129 -32
- package/dist/cjs/Message/Message.test.js +71 -0
- package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
- package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.js +5 -0
- package/dist/cjs/Message/UserFeedback/UserFeedback.d.ts +15 -1
- package/dist/cjs/Message/UserFeedback/UserFeedback.js +4 -4
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +44 -0
- package/dist/cjs/MessageBar/MessageBar.js +19 -4
- package/dist/cjs/MessageBox/JumpButton.d.ts +5 -0
- package/dist/cjs/MessageBox/JumpButton.js +1 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
- package/dist/cjs/MessageBox/MessageBox.d.ts +9 -0
- package/dist/cjs/MessageBox/MessageBox.js +2 -2
- package/dist/cjs/MessageBox/MessageBox.test.js +2 -2
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +13 -1
- package/dist/cjs/SourcesCard/SourcesCard.js +6 -6
- package/dist/cjs/SourcesCard/SourcesCard.test.js +49 -0
- package/dist/cjs/ToolResponse/ToolResponse.d.ts +30 -0
- package/dist/cjs/ToolResponse/ToolResponse.js +18 -0
- package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +1 -0
- package/dist/cjs/ToolResponse/ToolResponse.test.js +60 -0
- package/dist/cjs/ToolResponse/index.d.ts +2 -0
- package/dist/cjs/ToolResponse/index.js +23 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +13 -1
- package/dist/css/main.css +339 -27
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/DeepThinking/package.json +1 -0
- package/dist/dynamic/FilePreview/package.json +1 -0
- package/dist/dynamic/ImagePreview/package.json +1 -0
- package/dist/dynamic/ToolResponse/package.json +1 -0
- package/dist/esm/Chatbot/Chatbot.js +1 -7
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -11
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +41 -3
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.js +22 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +20 -0
- package/dist/esm/ChatbotHeader/index.d.ts +1 -0
- package/dist/esm/ChatbotHeader/index.js +1 -0
- package/dist/esm/DeepThinking/DeepThinking.d.ts +18 -0
- package/dist/esm/DeepThinking/DeepThinking.js +14 -0
- package/dist/esm/DeepThinking/DeepThinking.test.d.ts +1 -0
- package/dist/esm/DeepThinking/DeepThinking.test.js +43 -0
- package/dist/esm/DeepThinking/index.d.ts +2 -0
- package/dist/esm/DeepThinking/index.js +2 -0
- package/dist/esm/FileDetails/FileDetails.d.ts +22 -3
- package/dist/esm/FileDetails/FileDetails.js +27 -912
- package/dist/esm/FileDetails/FileDetails.test.js +16 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.d.ts +8 -2
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.js +14 -2
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +19 -1
- package/dist/esm/FilePreview/FilePreview.d.ts +26 -0
- package/dist/esm/FilePreview/FilePreview.js +21 -0
- package/dist/esm/FilePreview/FilePreview.test.d.ts +1 -0
- package/dist/esm/FilePreview/FilePreview.test.js +92 -0
- package/dist/esm/FilePreview/index.d.ts +2 -0
- package/dist/esm/FilePreview/index.js +2 -0
- package/dist/esm/ImagePreview/ImagePreview.d.ts +53 -0
- package/dist/esm/ImagePreview/ImagePreview.js +42 -0
- package/dist/esm/ImagePreview/ImagePreview.test.d.ts +1 -0
- package/dist/esm/ImagePreview/ImagePreview.test.js +220 -0
- package/dist/esm/ImagePreview/index.d.ts +2 -0
- package/dist/esm/ImagePreview/index.js +2 -0
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +5 -5
- package/dist/esm/Message/LinkMessage/LinkMessage.d.ts +2 -1
- package/dist/esm/Message/LinkMessage/LinkMessage.js +7 -3
- package/dist/esm/Message/ListMessage/ListItemMessage.d.ts +1 -1
- package/dist/esm/Message/ListMessage/ListItemMessage.js +16 -1
- package/dist/esm/Message/Message.d.ts +15 -0
- package/dist/esm/Message/Message.js +129 -32
- package/dist/esm/Message/Message.test.js +71 -0
- package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
- package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.js +3 -0
- package/dist/esm/Message/UserFeedback/UserFeedback.d.ts +15 -1
- package/dist/esm/Message/UserFeedback/UserFeedback.js +4 -4
- package/dist/esm/Message/UserFeedback/UserFeedback.test.js +45 -1
- package/dist/esm/MessageBar/MessageBar.js +19 -4
- package/dist/esm/MessageBox/JumpButton.d.ts +5 -0
- package/dist/esm/MessageBox/JumpButton.js +1 -1
- package/dist/esm/MessageBox/JumpButton.test.js +4 -4
- package/dist/esm/MessageBox/MessageBox.d.ts +9 -0
- package/dist/esm/MessageBox/MessageBox.js +2 -2
- package/dist/esm/MessageBox/MessageBox.test.js +2 -2
- package/dist/esm/SourcesCard/SourcesCard.d.ts +13 -1
- package/dist/esm/SourcesCard/SourcesCard.js +6 -6
- package/dist/esm/SourcesCard/SourcesCard.test.js +50 -1
- package/dist/esm/ToolResponse/ToolResponse.d.ts +30 -0
- package/dist/esm/ToolResponse/ToolResponse.js +14 -0
- package/dist/esm/ToolResponse/ToolResponse.test.d.ts +1 -0
- package/dist/esm/ToolResponse/ToolResponse.test.js +55 -0
- package/dist/esm/ToolResponse/index.d.ts +2 -0
- package/dist/esm/ToolResponse/index.js +2 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +101 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FilePreview.tsx +33 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/ImagePreview.tsx +53 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDeepThinking.tsx +17 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +111 -85
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +70 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx +135 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +38 -4
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +107 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +616 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/file-preview.svg +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotConversationEditing.tsx +202 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +17 -3
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +36 -5
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +12 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +22 -3
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +1 -1
- package/patternfly-docs/patternfly-docs.config.js +1 -1
- package/src/Chatbot/Chatbot.scss +9 -2
- package/src/Chatbot/Chatbot.tsx +18 -31
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +5 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +16 -10
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +132 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +80 -33
- package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +1 -1
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx +25 -0
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx +64 -0
- package/src/ChatbotHeader/index.ts +1 -0
- package/src/ChatbotModal/ChatbotModal.scss +1 -1
- package/src/DeepThinking/DeepThinking.scss +24 -0
- package/src/DeepThinking/DeepThinking.test.tsx +61 -0
- package/src/DeepThinking/DeepThinking.tsx +68 -0
- package/src/DeepThinking/index.ts +3 -0
- package/src/FileDetails/FileDetails.scss +10 -0
- package/src/FileDetails/FileDetails.test.tsx +16 -0
- package/src/FileDetails/FileDetails.tsx +89 -32
- package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +20 -14
- package/src/FileDetailsLabel/FileDetailsLabel.test.tsx +21 -1
- package/src/FileDetailsLabel/FileDetailsLabel.tsx +16 -3
- package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +20 -14
- package/src/FilePreview/FilePreview.scss +22 -0
- package/src/FilePreview/FilePreview.test.tsx +112 -0
- package/src/FilePreview/FilePreview.tsx +58 -0
- package/src/FilePreview/index.ts +3 -0
- package/src/ImagePreview/ImagePreview.scss +61 -0
- package/src/ImagePreview/ImagePreview.test.tsx +253 -0
- package/src/ImagePreview/ImagePreview.tsx +200 -0
- package/src/ImagePreview/index.ts +3 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +2 -1
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +6 -5
- package/src/Message/LinkMessage/LinkMessage.tsx +6 -2
- package/src/Message/ListMessage/ListItemMessage.tsx +5 -1
- package/src/Message/ListMessage/ListMessage.scss +17 -0
- package/src/Message/Message.scss +44 -0
- package/src/Message/Message.test.tsx +90 -0
- package/src/Message/Message.tsx +171 -46
- package/src/Message/SuperscriptMessage/SuperscriptMessage.scss +8 -0
- package/src/Message/SuperscriptMessage/SuperscriptMessage.tsx +13 -0
- package/src/Message/TextMessage/TextMessage.scss +46 -5
- package/src/Message/UserFeedback/UserFeedback.test.tsx +107 -0
- package/src/Message/UserFeedback/UserFeedback.tsx +41 -6
- package/src/MessageBar/MessageBar.tsx +23 -3
- package/src/MessageBox/JumpButton.test.tsx +4 -4
- package/src/MessageBox/JumpButton.tsx +20 -4
- package/src/MessageBox/MessageBox.scss +0 -12
- package/src/MessageBox/MessageBox.test.tsx +2 -2
- package/src/MessageBox/MessageBox.tsx +23 -2
- package/src/SourcesCard/SourcesCard.scss +17 -0
- package/src/SourcesCard/SourcesCard.test.tsx +93 -0
- package/src/SourcesCard/SourcesCard.tsx +116 -80
- package/src/ToolResponse/ToolResponse.scss +36 -0
- package/src/ToolResponse/ToolResponse.test.tsx +78 -0
- package/src/ToolResponse/ToolResponse.tsx +95 -0
- package/src/ToolResponse/index.ts +3 -0
- package/src/index.ts +12 -0
- package/src/main.scss +16 -0
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
+
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
|
+
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
4
|
+
import { CopyIcon, WrenchIcon } from '@patternfly/react-icons';
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
DescriptionList,
|
|
8
|
+
DescriptionListDescription,
|
|
9
|
+
DescriptionListGroup,
|
|
10
|
+
DescriptionListTerm,
|
|
11
|
+
ExpandableSection,
|
|
12
|
+
ExpandableSectionVariant,
|
|
13
|
+
Flex,
|
|
14
|
+
FlexItem,
|
|
15
|
+
Label
|
|
16
|
+
} from '@patternfly/react-core';
|
|
17
|
+
|
|
18
|
+
export const MessageWithToolResponseExample: FunctionComponent = () => {
|
|
19
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
20
|
+
|
|
21
|
+
const onToggle = (_event: ReactMouseEvent, isExpanded: boolean) => {
|
|
22
|
+
setIsExpanded(isExpanded);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Message
|
|
27
|
+
name="Bot"
|
|
28
|
+
role="bot"
|
|
29
|
+
avatar={patternflyAvatar}
|
|
30
|
+
content="This example has a body description that's within the recommended limit of 2 lines:"
|
|
31
|
+
toolResponse={{
|
|
32
|
+
toggleContent: 'Tool response: toolName',
|
|
33
|
+
subheading: 'Thought for 3 seconds',
|
|
34
|
+
body: "Here's the summary for your toolName response:",
|
|
35
|
+
cardTitle: (
|
|
36
|
+
<Flex alignItems={{ default: 'alignItemsCenter' }} justifyContent={{ default: 'justifyContentSpaceBetween' }}>
|
|
37
|
+
<FlexItem>
|
|
38
|
+
<Flex direction={{ default: 'column' }} gap={{ default: 'gapXs' }}>
|
|
39
|
+
<FlexItem grow={{ default: 'grow' }}>
|
|
40
|
+
<Flex gap={{ default: 'gapXs' }}>
|
|
41
|
+
<FlexItem>
|
|
42
|
+
<WrenchIcon style={{ color: 'var(--pf-t--global--icon--color--brand--default' }} />
|
|
43
|
+
</FlexItem>
|
|
44
|
+
<FlexItem>toolName</FlexItem>
|
|
45
|
+
</Flex>
|
|
46
|
+
</FlexItem>
|
|
47
|
+
<FlexItem>
|
|
48
|
+
<Flex gap={{ default: 'gapSm' }} style={{ fontSize: '12px', fontWeight: '400' }}>
|
|
49
|
+
<FlexItem>Execution time:</FlexItem>
|
|
50
|
+
<FlexItem>0.12 seconds</FlexItem>
|
|
51
|
+
</Flex>
|
|
52
|
+
</FlexItem>
|
|
53
|
+
</Flex>
|
|
54
|
+
</FlexItem>
|
|
55
|
+
<FlexItem>
|
|
56
|
+
<Button
|
|
57
|
+
variant="plain"
|
|
58
|
+
aria-label="Copy tool response to clipboard"
|
|
59
|
+
icon={<CopyIcon style={{ color: 'var(--pf-t--global--icon--color--subtle)' }} />}
|
|
60
|
+
></Button>
|
|
61
|
+
</FlexItem>
|
|
62
|
+
</Flex>
|
|
63
|
+
),
|
|
64
|
+
cardBody: (
|
|
65
|
+
<>
|
|
66
|
+
<DescriptionList
|
|
67
|
+
style={{ '--pf-v6-c-description-list--RowGap': 'var(--pf-t--global--spacer--md)' } as any}
|
|
68
|
+
aria-label="Tool response"
|
|
69
|
+
>
|
|
70
|
+
<DescriptionListGroup
|
|
71
|
+
style={{ '--pf-v6-c-description-list__group--RowGap': 'var(--pf-t--global--spacer--xs)' } as any}
|
|
72
|
+
>
|
|
73
|
+
<DescriptionListTerm>Parameters</DescriptionListTerm>
|
|
74
|
+
<DescriptionListDescription>
|
|
75
|
+
<Flex direction={{ default: 'column' }}>
|
|
76
|
+
<FlexItem>Optional description text for parameters.</FlexItem>
|
|
77
|
+
<FlexItem>
|
|
78
|
+
<Flex gap={{ default: 'gapSm' }}>
|
|
79
|
+
<FlexItem>
|
|
80
|
+
<Label variant="outline" color="blue">
|
|
81
|
+
type
|
|
82
|
+
</Label>
|
|
83
|
+
</FlexItem>
|
|
84
|
+
<FlexItem>
|
|
85
|
+
<Label variant="outline" color="blue">
|
|
86
|
+
properties
|
|
87
|
+
</Label>
|
|
88
|
+
</FlexItem>
|
|
89
|
+
<FlexItem>
|
|
90
|
+
<Label variant="outline" color="blue">
|
|
91
|
+
label
|
|
92
|
+
</Label>
|
|
93
|
+
</FlexItem>
|
|
94
|
+
<FlexItem>
|
|
95
|
+
<Label variant="outline" color="blue">
|
|
96
|
+
label
|
|
97
|
+
</Label>
|
|
98
|
+
</FlexItem>
|
|
99
|
+
</Flex>
|
|
100
|
+
</FlexItem>
|
|
101
|
+
</Flex>
|
|
102
|
+
</DescriptionListDescription>
|
|
103
|
+
</DescriptionListGroup>
|
|
104
|
+
<DescriptionListGroup
|
|
105
|
+
style={{ '--pf-v6-c-description-list__group--RowGap': 'var(--pf-t--global--spacer--xs)' } as any}
|
|
106
|
+
>
|
|
107
|
+
<DescriptionListTerm>Response</DescriptionListTerm>
|
|
108
|
+
<DescriptionListDescription>
|
|
109
|
+
<ExpandableSection
|
|
110
|
+
variant={ExpandableSectionVariant.truncate}
|
|
111
|
+
toggleTextExpanded="show less of response"
|
|
112
|
+
toggleTextCollapsed="show more of response"
|
|
113
|
+
onToggle={onToggle}
|
|
114
|
+
isExpanded={isExpanded}
|
|
115
|
+
style={
|
|
116
|
+
{
|
|
117
|
+
'--pf-v6-c-expandable-section__content--Opacity': '1',
|
|
118
|
+
'--pf-v6-c-expandable-section__content--PaddingInlineStart': 0,
|
|
119
|
+
'--pf-v6-c-expandable-section__content--TranslateY': 0,
|
|
120
|
+
'--pf-v6-c-expandable-section--m-expand-top__content--TranslateY': 0
|
|
121
|
+
} as any
|
|
122
|
+
}
|
|
123
|
+
>
|
|
124
|
+
Descriptive text about the tool response, including completion status, details on the data that was
|
|
125
|
+
processed, or anything else relevant to the use case.
|
|
126
|
+
</ExpandableSection>
|
|
127
|
+
</DescriptionListDescription>
|
|
128
|
+
</DescriptionListGroup>
|
|
129
|
+
</DescriptionList>
|
|
130
|
+
</>
|
|
131
|
+
)
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
@@ -34,10 +34,7 @@ import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
|
34
34
|
import MessageDivider from '@patternfly/chatbot/dist/dynamic/MessageDivider';
|
|
35
35
|
import { rehypeCodeBlockToggle } from '@patternfly/chatbot/dist/esm/Message/Plugins/rehypeCodeBlockToggle';
|
|
36
36
|
import SourcesCard from '@patternfly/chatbot/dist/dynamic/SourcesCard';
|
|
37
|
-
import { RobotIcon } from '@patternfly/react-icons
|
|
38
|
-
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
39
|
-
import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon';
|
|
40
|
-
import RedoIcon from '@patternfly/react-icons/dist/esm/icons/redo-icon';
|
|
37
|
+
import { ArrowCircleDownIcon, ArrowRightIcon, CheckCircleIcon, CopyIcon, CubeIcon, CubesIcon, DownloadIcon, InfoCircleIcon, OutlinedQuestionCircleIcon, RedoIcon, RobotIcon, WrenchIcon } from '@patternfly/react-icons';
|
|
41
38
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
42
39
|
import AttachmentEdit from '@patternfly/chatbot/dist/dynamic/AttachmentEdit';
|
|
43
40
|
import FileDetails from '@patternfly/chatbot/dist/dynamic/FileDetails';
|
|
@@ -50,6 +47,9 @@ import { monitorSampleAppQuickStart } from '@patternfly/chatbot/src/Message/Quic
|
|
|
50
47
|
import userAvatar from './user_avatar.svg';
|
|
51
48
|
import squareImg from './PF-social-color-square.svg';
|
|
52
49
|
import { CSSProperties, useState, Fragment, FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent, Ref, isValidElement, cloneElement, Children, ReactNode, useRef, useEffect } from 'react';
|
|
50
|
+
import FilePreview from '@patternfly/chatbot/dist/dynamic/FilePreview';
|
|
51
|
+
import ImagePreview from '@patternfly/chatbot/dist/dynamic/ImagePreview';
|
|
52
|
+
import filePreview from './file-preview.svg';
|
|
53
53
|
|
|
54
54
|
The `content` prop of the `<Message>` component is passed to a `<Markdown>` component (from [react-markdown](https://remarkjs.github.io/react-markdown/)), which is configured to translate plain text strings into PatternFly [`<Content>` components](/components/content) and code blocks into PatternFly [`<CodeBlock>` components.](/components/code-block)
|
|
55
55
|
|
|
@@ -181,6 +181,24 @@ The API for a source requires a link at minimum, but we strongly recommend provi
|
|
|
181
181
|
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
+
### Messages with tool responses
|
|
185
|
+
|
|
186
|
+
If you are using [model context protocol (MCP)](https://www.redhat.com/en/blog/model-context-protocol-discover-missing-link-ai-integration), you may find it useful to display information on tool responses as part of a message. Passing `toolResponse` to `<Message>` allows you to display a card with an optional subheading and body, as well as custom card content. Content is intentionally left fully customizable for now as this is an evolving area.
|
|
187
|
+
|
|
188
|
+
```js file="./MessageWithToolResponse.tsx"
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Messages with deep thinking
|
|
193
|
+
|
|
194
|
+
You can share details about the "thought process" behind an LLM's response, also known as deep thinking. To display a customizable, expandable card with these details, pass `deepThinking` to `<Message>` and provide a subheading (optional) and content body.
|
|
195
|
+
|
|
196
|
+
Because this is an evolving area, this card content is currently fully customizable.
|
|
197
|
+
|
|
198
|
+
```js file="./MessageWithDeepThinking.tsx"
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
|
|
184
202
|
### Messages with quick start tiles
|
|
185
203
|
|
|
186
204
|
[Quick start](/extensions/quick-starts/) tiles can be added to messages via the `quickStarts` prop. Users can initiate the quick start from a link within the message tile.
|
|
@@ -258,6 +276,22 @@ To allow users to edit an attached file, load a new code editor within the ChatB
|
|
|
258
276
|
|
|
259
277
|
```
|
|
260
278
|
|
|
279
|
+
### Image preview
|
|
280
|
+
|
|
281
|
+
To allow users to preview images, load a modal that contains a view of the file name, file size, and the image. Users can toggle between multiple images by using pagination controls at the bottom of the modal. Return users to the main ChatBot window once they close the modal.
|
|
282
|
+
|
|
283
|
+
```js file="./ImagePreview.tsx"
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### File preview
|
|
288
|
+
|
|
289
|
+
If the contents of an attachment cannot be previewed, load a file preview modal with a view of the file name and an unavailable message. When users close the modal, return to the main ChatBot window.
|
|
290
|
+
|
|
291
|
+
```js file="./FilePreview.tsx"
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
|
|
261
295
|
### Failed attachment error
|
|
262
296
|
|
|
263
297
|
When an attachment upload fails, a [danger alert](/components/alert) is displayed to provide details about the reason for failure.
|
|
@@ -19,7 +19,7 @@ export const PreviewAttachmentExample: FunctionComponent = () => {
|
|
|
19
19
|
id="modal-compact-preview"
|
|
20
20
|
name="modal-compact-preview"
|
|
21
21
|
></Checkbox>
|
|
22
|
-
<Button onClick={handleModalToggle}>Launch modal</Button>
|
|
22
|
+
<Button onClick={handleModalToggle}>Launch attachment preview modal</Button>
|
|
23
23
|
<PreviewAttachment
|
|
24
24
|
code="I am a code snippet"
|
|
25
25
|
fileName="test.yaml"
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Fragment,
|
|
3
|
+
useState,
|
|
4
|
+
useRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
CSSProperties,
|
|
7
|
+
FunctionComponent,
|
|
8
|
+
MouseEvent as ReactMouseEvent,
|
|
9
|
+
KeyboardEvent as ReactKeyboardEvent,
|
|
10
|
+
Ref
|
|
11
|
+
} from 'react';
|
|
2
12
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
13
|
import userAvatar from './user_avatar.svg';
|
|
4
14
|
import {
|
|
@@ -64,6 +74,8 @@ export const UserMessageExample: FunctionComponent = () => {
|
|
|
64
74
|
return table;
|
|
65
75
|
case 'Image':
|
|
66
76
|
return image;
|
|
77
|
+
case 'Footnote':
|
|
78
|
+
return footnote;
|
|
67
79
|
default:
|
|
68
80
|
return '';
|
|
69
81
|
}
|
|
@@ -170,6 +182,18 @@ _Italic text, formatted with single underscores_
|
|
|
170
182
|
|
|
171
183
|
const image = ``;
|
|
172
184
|
|
|
185
|
+
const footnote = `This is some text that has a short footnote[^1] and this is text with a longer footnote.[^bignote]
|
|
186
|
+
|
|
187
|
+
[^1]: This is a short footnote. To return the highlight to the original message, click the arrow.
|
|
188
|
+
|
|
189
|
+
[^bignote]: This is a long footnote with multiple paragraphs and formatting.
|
|
190
|
+
|
|
191
|
+
To break long footnotes into paragraphs, indent the text.
|
|
192
|
+
|
|
193
|
+
Add as many paragraphs as you like. You can include *italic text*, **bold text**, and \`code\`.
|
|
194
|
+
|
|
195
|
+
> You can even include blockquotes in footnotes!`;
|
|
196
|
+
|
|
173
197
|
const error = {
|
|
174
198
|
title: 'Could not load chat',
|
|
175
199
|
children: 'Wait a few minutes and check your network settings. If the issue persists: ',
|
|
@@ -185,7 +209,7 @@ _Italic text, formatted with single underscores_
|
|
|
185
209
|
)
|
|
186
210
|
};
|
|
187
211
|
|
|
188
|
-
const onSelect = (_event:
|
|
212
|
+
const onSelect = (_event: ReactMouseEvent<Element> | undefined, value: string | number | undefined) => {
|
|
189
213
|
setVariant(value);
|
|
190
214
|
setSelected(value as string);
|
|
191
215
|
setIsOpen(false);
|
|
@@ -221,6 +245,78 @@ _Italic text, formatted with single underscores_
|
|
|
221
245
|
</MenuToggle>
|
|
222
246
|
);
|
|
223
247
|
|
|
248
|
+
const handleFootnoteNavigation = (event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>) => {
|
|
249
|
+
const target = event.target as HTMLElement;
|
|
250
|
+
|
|
251
|
+
// Depending on whether it is a click event or keyboard event, target may be a link or something like a span
|
|
252
|
+
// Look for the closest anchor element (could be a parent)
|
|
253
|
+
const anchorElement = target.closest('a');
|
|
254
|
+
const href = anchorElement?.getAttribute('href');
|
|
255
|
+
|
|
256
|
+
// Check if this is a footnote link - we only have internal links in this example, so this is all we need here
|
|
257
|
+
if (href && href.startsWith('#')) {
|
|
258
|
+
// Prevent default behavior to avoid page re-render on click in PatternFly docs framework
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
|
|
261
|
+
let targetElement: HTMLElement | null = null;
|
|
262
|
+
const targetId = href.replace('#', '');
|
|
263
|
+
targetElement = document.querySelector(`[id="${targetId}"]`);
|
|
264
|
+
|
|
265
|
+
if (targetElement) {
|
|
266
|
+
let focusTarget = targetElement;
|
|
267
|
+
|
|
268
|
+
// If we found a footnote definition container, focus on the parent li element
|
|
269
|
+
if (targetElement.id?.startsWith('user-message-fn-')) {
|
|
270
|
+
// Find the parent li element that contains the footnote
|
|
271
|
+
const parentLi = targetElement.closest('li');
|
|
272
|
+
if (parentLi) {
|
|
273
|
+
focusTarget = parentLi as HTMLElement;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
focusTarget.focus();
|
|
278
|
+
|
|
279
|
+
let elementToHighlight = targetElement;
|
|
280
|
+
const searchStartElement = targetElement;
|
|
281
|
+
let elementToHighlightContainer: HTMLElement | null = null;
|
|
282
|
+
|
|
283
|
+
// For footnote references, look for an appropriate container
|
|
284
|
+
if (!targetElement.id?.startsWith('user-message-fn-')) {
|
|
285
|
+
let parent = searchStartElement.parentElement;
|
|
286
|
+
while (
|
|
287
|
+
parent &&
|
|
288
|
+
!(parent.tagName.toLowerCase() === 'span' && parent.classList.contains('pf-chatbot__message-text')) &&
|
|
289
|
+
parent !== document.body
|
|
290
|
+
) {
|
|
291
|
+
parent = parent.parentElement;
|
|
292
|
+
}
|
|
293
|
+
elementToHighlightContainer = parent;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Use the found container if available, otherwise fall back to the target element
|
|
297
|
+
elementToHighlight = elementToHighlightContainer || targetElement;
|
|
298
|
+
|
|
299
|
+
// Briefly highlight the target element for fun to show what you can do
|
|
300
|
+
const originalBackground = elementToHighlight.style.backgroundColor;
|
|
301
|
+
const originalTransition = elementToHighlight.style.transition;
|
|
302
|
+
|
|
303
|
+
elementToHighlight.style.transition = 'background-color 0.3s ease';
|
|
304
|
+
elementToHighlight.style.backgroundColor = 'var(--pf-t--global--icon--color--brand--hover)';
|
|
305
|
+
|
|
306
|
+
setTimeout(() => {
|
|
307
|
+
elementToHighlight.style.backgroundColor = originalBackground;
|
|
308
|
+
setTimeout(() => {
|
|
309
|
+
elementToHighlight.style.transition = originalTransition;
|
|
310
|
+
}, 300);
|
|
311
|
+
}, 1000);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const onClick = (event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>) => {
|
|
317
|
+
handleFootnoteNavigation(event);
|
|
318
|
+
};
|
|
319
|
+
|
|
224
320
|
return (
|
|
225
321
|
<>
|
|
226
322
|
<Message
|
|
@@ -270,6 +366,7 @@ _Italic text, formatted with single underscores_
|
|
|
270
366
|
<SelectOption value="More complex list">More complex list</SelectOption>
|
|
271
367
|
<SelectOption value="Table">Table</SelectOption>
|
|
272
368
|
<SelectOption value="Image">Image</SelectOption>
|
|
369
|
+
<SelectOption value="Footnote">Footnote</SelectOption>
|
|
273
370
|
<SelectOption value="Error">Error</SelectOption>
|
|
274
371
|
</SelectList>
|
|
275
372
|
</Select>
|
|
@@ -287,6 +384,14 @@ _Italic text, formatted with single underscores_
|
|
|
287
384
|
// The purpose of this plugin is to provide unique link names for the code blocks
|
|
288
385
|
// Because they are in the same message, this requires a custom plugin to parse the syntax tree
|
|
289
386
|
additionalRehypePlugins={[rehypeCodeBlockToggle]}
|
|
387
|
+
linkProps={{ onClick }}
|
|
388
|
+
// clobberPrefix controls the label ids
|
|
389
|
+
reactMarkdownProps={{
|
|
390
|
+
remarkRehypeOptions: {
|
|
391
|
+
footnoteLabel: 'User message footnotes',
|
|
392
|
+
clobberPrefix: 'user-message-'
|
|
393
|
+
}
|
|
394
|
+
}}
|
|
290
395
|
/>
|
|
291
396
|
</>
|
|
292
397
|
);
|