@red-hat-developer-hub/backstage-plugin-intelligent-assistant 4.3.0 → 5.0.1
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/CHANGELOG.md +20 -0
- package/README.md +6 -7
- package/dist/components/Attachment.esm.js +4 -2
- package/dist/components/Attachment.esm.js.map +1 -1
- package/dist/components/DeleteModal.esm.js +1 -0
- package/dist/components/DeleteModal.esm.js.map +1 -1
- package/dist/components/LightSpeedChat.esm.js +2 -2
- package/dist/components/LightSpeedChat.esm.js.map +1 -1
- package/dist/components/LightspeedChatBox.esm.js +44 -71
- package/dist/components/LightspeedChatBox.esm.js.map +1 -1
- package/dist/components/LightspeedChatContainer.esm.js +2 -3
- package/dist/components/LightspeedChatContainer.esm.js.map +1 -1
- package/dist/components/McpServersSettings.esm.js +5 -5
- package/dist/components/McpServersSettings.esm.js.map +1 -1
- package/dist/components/RagSourceLabel.esm.js +22 -0
- package/dist/components/RagSourceLabel.esm.js.map +1 -0
- package/dist/components/SourcesChipModal.esm.js +94 -89
- package/dist/components/SourcesChipModal.esm.js.map +1 -1
- package/dist/hooks/notebooks/useLightspeedNotebooksPermission.esm.js +3 -3
- package/dist/hooks/notebooks/useLightspeedNotebooksPermission.esm.js.map +1 -1
- package/dist/hooks/useFeedbackActions.esm.js.map +1 -1
- package/dist/hooks/useLightspeedDeletePermission.esm.js +2 -2
- package/dist/hooks/useLightspeedDeletePermission.esm.js.map +1 -1
- package/dist/hooks/useLightspeedUpdatePermission.esm.js +2 -2
- package/dist/hooks/useLightspeedUpdatePermission.esm.js.map +1 -1
- package/dist/hooks/useLightspeedViewPermission.esm.js +6 -10
- package/dist/hooks/useLightspeedViewPermission.esm.js.map +1 -1
- package/dist/types.esm.js.map +1 -1
- package/dist/utils/lightspeed-chatbox-utils.esm.js +13 -6
- package/dist/utils/lightspeed-chatbox-utils.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,85 +1,62 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { Popover, Button, HelperText, List, ListItem, HelperTextItem, Tooltip } from '@patternfly/react-core';
|
|
4
5
|
import { LinkIcon, InfoCircleIcon } from '@patternfly/react-icons';
|
|
5
6
|
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
6
7
|
import { FileTypeIcon } from './notebooks/FileTypeIcon.esm.js';
|
|
8
|
+
import { RagSourceLabel } from './RagSourceLabel.esm.js';
|
|
7
9
|
|
|
8
10
|
const POPOVER_WIDTH = "400px";
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
alignItems: "flex-start"
|
|
13
|
-
},
|
|
14
|
-
"& .pf-v6-c-popover__title-text": {
|
|
15
|
-
margin: 0
|
|
16
|
-
},
|
|
17
|
-
"& .pf-v6-c-popover__header": {
|
|
18
|
-
paddingBlockEnd: theme.spacing(2)
|
|
19
|
-
},
|
|
20
|
-
"& .pf-v6-c-popover__body": {
|
|
21
|
-
paddingBlockStart: 0
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
chipButton: {
|
|
25
|
-
padding: "4px 12px",
|
|
26
|
-
fontSize: "0.8125rem",
|
|
27
|
-
fontWeight: 500,
|
|
28
|
-
borderRadius: 16,
|
|
29
|
-
backgroundColor: "transparent",
|
|
30
|
-
color: "var(--pf-t--global--text--color--regular, #1b1d21)",
|
|
31
|
-
"&:hover": {
|
|
32
|
-
backgroundColor: "var(--pf-t--global--background--color--secondary--default, #e0e0e0)"
|
|
33
|
-
},
|
|
34
|
-
"& .pf-v6-c-button__icon": {
|
|
35
|
-
color: "inherit"
|
|
36
|
-
}
|
|
11
|
+
const SourcesPopover = styled(Popover)(({ theme }) => ({
|
|
12
|
+
"& .pf-v6-c-popover__title": {
|
|
13
|
+
alignItems: "flex-start"
|
|
37
14
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
color: "var(--pf-t--global--text--color--subtle, #c7c7c7)"
|
|
15
|
+
"& .pf-v6-c-popover__title-text": {
|
|
16
|
+
margin: 0
|
|
41
17
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
overflowY: "auto"
|
|
18
|
+
"& .pf-v6-c-popover__header": {
|
|
19
|
+
paddingBlockEnd: theme.spacing(2)
|
|
45
20
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
overflow: "hidden",
|
|
60
|
-
textOverflow: "ellipsis",
|
|
61
|
-
whiteSpace: "nowrap"
|
|
21
|
+
"& .pf-v6-c-popover__body": {
|
|
22
|
+
paddingBlockStart: 0
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
const ChipButton = styled(Button)({
|
|
26
|
+
padding: "4px 12px",
|
|
27
|
+
fontSize: "0.8125rem",
|
|
28
|
+
fontWeight: 500,
|
|
29
|
+
borderRadius: 16,
|
|
30
|
+
backgroundColor: "transparent",
|
|
31
|
+
color: "var(--pf-t--global--text--color--regular)",
|
|
32
|
+
"&:hover": {
|
|
33
|
+
backgroundColor: "var(--pf-t--global--background--color--secondary--default)"
|
|
62
34
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
color: "var(--pf-t--global--text--color--subtle, #c7c7c7)",
|
|
66
|
-
marginTop: 2,
|
|
67
|
-
overflow: "hidden",
|
|
68
|
-
textOverflow: "ellipsis",
|
|
69
|
-
display: "-webkit-box",
|
|
70
|
-
WebkitLineClamp: 2,
|
|
71
|
-
WebkitBoxOrient: "vertical"
|
|
35
|
+
"& .pf-v6-c-button__icon": {
|
|
36
|
+
color: "inherit"
|
|
72
37
|
}
|
|
38
|
+
});
|
|
39
|
+
const SourcesHelperText = styled(HelperText)(({ theme }) => ({
|
|
40
|
+
marginBottom: theme.spacing(1.5),
|
|
41
|
+
color: "var(--pf-t--global--text--color--subtle)"
|
|
73
42
|
}));
|
|
43
|
+
const SourcesList = styled(List)({
|
|
44
|
+
maxHeight: 320,
|
|
45
|
+
overflowY: "auto"
|
|
46
|
+
});
|
|
47
|
+
const SourceListItem = styled(ListItem)({
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
"& .pf-v6-c-list__item-text": {
|
|
50
|
+
minWidth: 0
|
|
51
|
+
}
|
|
52
|
+
});
|
|
74
53
|
const SourcesChipModal = ({ sources }) => {
|
|
75
|
-
const classes = useStyles();
|
|
76
54
|
const { t } = useTranslation();
|
|
77
55
|
const count = sources.sources?.length ?? 0;
|
|
78
56
|
if (count === 0) return null;
|
|
79
57
|
return /* @__PURE__ */ jsx(
|
|
80
|
-
|
|
58
|
+
SourcesPopover,
|
|
81
59
|
{
|
|
82
|
-
className: classes.sourcesPopover,
|
|
83
60
|
position: "top-start",
|
|
84
61
|
triggerAction: "click",
|
|
85
62
|
"aria-label": t("sources.modal.title"),
|
|
@@ -90,32 +67,60 @@ const SourcesChipModal = ({ sources }) => {
|
|
|
90
67
|
maxWidth: POPOVER_WIDTH,
|
|
91
68
|
appendTo: () => document.body,
|
|
92
69
|
bodyContent: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
94
|
-
/* @__PURE__ */ jsx(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
70
|
+
/* @__PURE__ */ jsx(SourcesHelperText, { children: /* @__PURE__ */ jsx(HelperTextItem, { variant: "indeterminate", icon: /* @__PURE__ */ jsx(InfoCircleIcon, {}), children: t("sources.modal.description") }) }),
|
|
71
|
+
/* @__PURE__ */ jsx(SourcesList, { isPlain: true, "aria-label": t("sources.modal.title"), children: sources.sources.map((source, index) => {
|
|
72
|
+
const title = source.title ?? `Source ${index + 1}`;
|
|
73
|
+
const ragSource = source.ragSource;
|
|
74
|
+
const titleNode = /* @__PURE__ */ jsx(
|
|
75
|
+
Box,
|
|
76
|
+
{
|
|
77
|
+
sx: {
|
|
78
|
+
fontSize: "0.875rem",
|
|
79
|
+
fontWeight: 500,
|
|
80
|
+
overflow: "hidden",
|
|
81
|
+
textOverflow: "ellipsis",
|
|
82
|
+
whiteSpace: "nowrap",
|
|
83
|
+
minWidth: 0
|
|
84
|
+
},
|
|
85
|
+
children: title
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
SourceListItem,
|
|
90
|
+
{
|
|
91
|
+
icon: /* @__PURE__ */ jsx(FileTypeIcon, { fileName: title }),
|
|
92
|
+
children: /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Tooltip, { content: title, children: titleNode }),
|
|
94
|
+
ragSource && /* @__PURE__ */ jsx(
|
|
95
|
+
Box,
|
|
96
|
+
{
|
|
97
|
+
sx: { marginTop: "var(--pf-t--global--spacer--xs)" },
|
|
98
|
+
children: /* @__PURE__ */ jsx(RagSourceLabel, { source: ragSource })
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
source.body && /* @__PURE__ */ jsx(
|
|
102
|
+
Box,
|
|
103
|
+
{
|
|
104
|
+
sx: {
|
|
105
|
+
fontSize: "0.8125rem",
|
|
106
|
+
color: "var(--pf-t--global--text--color--subtle)",
|
|
107
|
+
marginTop: "2px",
|
|
108
|
+
overflow: "hidden",
|
|
109
|
+
textOverflow: "ellipsis",
|
|
110
|
+
display: "-webkit-box",
|
|
111
|
+
WebkitLineClamp: 2,
|
|
112
|
+
WebkitBoxOrient: "vertical"
|
|
113
|
+
},
|
|
114
|
+
children: source.body
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] })
|
|
118
|
+
},
|
|
119
|
+
`${source.title}-${index}`
|
|
120
|
+
);
|
|
121
|
+
}) })
|
|
117
122
|
] }),
|
|
118
|
-
children: /* @__PURE__ */ jsx(
|
|
123
|
+
children: /* @__PURE__ */ jsx(ChipButton, { variant: "link", icon: /* @__PURE__ */ jsx(LinkIcon, {}), children: t("sources.chip.label", { count }) })
|
|
119
124
|
}
|
|
120
125
|
);
|
|
121
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourcesChipModal.esm.js","sources":["../../src/components/SourcesChipModal.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"SourcesChipModal.esm.js","sources":["../../src/components/SourcesChipModal.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\nimport { SourcesCardProps } from '@patternfly/chatbot';\nimport {\n Button,\n HelperText,\n HelperTextItem,\n List,\n ListItem,\n Popover,\n Tooltip,\n} from '@patternfly/react-core';\nimport { InfoCircleIcon, LinkIcon } from '@patternfly/react-icons';\n\nimport { useTranslation } from '../hooks/useTranslation';\nimport { SourceWithRagId } from '../utils/lightspeed-chatbox-utils';\nimport { FileTypeIcon } from './notebooks/FileTypeIcon';\nimport { RagSourceLabel } from './RagSourceLabel';\n\nconst POPOVER_WIDTH = '400px';\n\nconst SourcesPopover = styled(Popover)(({ theme }) => ({\n '& .pf-v6-c-popover__title': {\n alignItems: 'flex-start',\n },\n '& .pf-v6-c-popover__title-text': {\n margin: 0,\n },\n '& .pf-v6-c-popover__header': {\n paddingBlockEnd: theme.spacing(2),\n },\n '& .pf-v6-c-popover__body': {\n paddingBlockStart: 0,\n },\n}));\n\nconst ChipButton = styled(Button)({\n padding: '4px 12px',\n fontSize: '0.8125rem',\n fontWeight: 500,\n borderRadius: 16,\n backgroundColor: 'transparent',\n color: 'var(--pf-t--global--text--color--regular)',\n '&:hover': {\n backgroundColor:\n 'var(--pf-t--global--background--color--secondary--default)',\n },\n '& .pf-v6-c-button__icon': {\n color: 'inherit',\n },\n});\n\nconst SourcesHelperText = styled(HelperText)(({ theme }) => ({\n marginBottom: theme.spacing(1.5),\n color: 'var(--pf-t--global--text--color--subtle)',\n}));\n\nconst SourcesList = styled(List)({\n maxHeight: 320,\n overflowY: 'auto',\n});\n\nconst SourceListItem = styled(ListItem)({\n alignItems: 'center',\n '& .pf-v6-c-list__item-text': {\n minWidth: 0,\n },\n});\n\ntype SourcesChipModalProps = {\n sources: SourcesCardProps;\n};\n\nexport const SourcesChipModal = ({ sources }: SourcesChipModalProps) => {\n const { t } = useTranslation();\n\n const count = sources.sources?.length ?? 0;\n if (count === 0) return null;\n\n return (\n <SourcesPopover\n position=\"top-start\"\n triggerAction=\"click\"\n aria-label={t('sources.modal.title')}\n headerContent={t('sources.modal.title')}\n headerIcon={<LinkIcon />}\n closeBtnAriaLabel={t('sources.popover.closeAriaLabel')}\n minWidth={POPOVER_WIDTH}\n maxWidth={POPOVER_WIDTH}\n appendTo={() => document.body}\n bodyContent={\n <>\n <SourcesHelperText>\n <HelperTextItem variant=\"indeterminate\" icon={<InfoCircleIcon />}>\n {t('sources.modal.description')}\n </HelperTextItem>\n </SourcesHelperText>\n <SourcesList isPlain aria-label={t('sources.modal.title')}>\n {sources.sources.map((source, index) => {\n const title = source.title ?? `Source ${index + 1}`;\n const ragSource = (source as SourceWithRagId).ragSource;\n const titleNode = (\n <Box\n sx={{\n fontSize: '0.875rem',\n fontWeight: 500,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n minWidth: 0,\n }}\n >\n {title}\n </Box>\n );\n return (\n <SourceListItem\n key={`${source.title}-${index}`}\n icon={<FileTypeIcon fileName={title} />}\n >\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Tooltip content={title}>{titleNode}</Tooltip>\n {ragSource && (\n <Box\n sx={{ marginTop: 'var(--pf-t--global--spacer--xs)' }}\n >\n <RagSourceLabel source={ragSource} />\n </Box>\n )}\n {source.body && (\n <Box\n sx={{\n fontSize: '0.8125rem',\n color: 'var(--pf-t--global--text--color--subtle)',\n marginTop: '2px',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n display: '-webkit-box',\n WebkitLineClamp: 2,\n WebkitBoxOrient: 'vertical',\n }}\n >\n {source.body}\n </Box>\n )}\n </Box>\n </SourceListItem>\n );\n })}\n </SourcesList>\n </>\n }\n >\n <ChipButton variant=\"link\" icon={<LinkIcon />}>\n {(t as Function)('sources.chip.label', { count })}\n </ChipButton>\n </SourcesPopover>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAmCA,MAAM,aAAA,GAAgB,OAAA;AAEtB,MAAM,iBAAiB,MAAA,CAAO,OAAO,EAAE,CAAC,EAAE,OAAM,MAAO;AAAA,EACrD,2BAAA,EAA6B;AAAA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AAA,EAAG,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,WA6B/B;AAAA,QAEJ,CAAC,CAAA,EACH;AAAA,OAAA,EACF,CAAA;AAAA,MAGF,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,MAAA,EAAO,IAAA,kBAAM,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA,EACvC,QAAA,EAAA,CAAA,CAAe,oBAAA,EAAsB,EAAE,KAAA,EAAO,CAAA,EAClD;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
2
|
-
import {
|
|
2
|
+
import { iaNotebooksPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';
|
|
3
3
|
|
|
4
4
|
const useLightspeedNotebooksPermission = () => {
|
|
5
5
|
const result = usePermission({
|
|
6
|
-
permission:
|
|
6
|
+
permission: iaNotebooksPermission
|
|
7
7
|
});
|
|
8
8
|
return {
|
|
9
9
|
loading: result.loading,
|
|
10
10
|
allowed: result.allowed,
|
|
11
|
-
|
|
11
|
+
iaNotebooksPermissionName: iaNotebooksPermission.name
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLightspeedNotebooksPermission.esm.js","sources":["../../../src/hooks/notebooks/useLightspeedNotebooksPermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useLightspeedNotebooksPermission.esm.js","sources":["../../../src/hooks/notebooks/useLightspeedNotebooksPermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport { iaNotebooksPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';\n\nexport const useLightspeedNotebooksPermission = () => {\n const result = usePermission({\n permission: iaNotebooksPermission,\n });\n\n return {\n loading: result.loading,\n allowed: result.allowed,\n iaNotebooksPermissionName: iaNotebooksPermission.name,\n };\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,mCAAmC,MAAM;AACpD,EAAA,MAAM,SAAS,aAAA,CAAc;AAAA,IAC3B,UAAA,EAAY;AAAA,GACb,CAAA;AAED,EAAA,OAAO;AAAA,IACL,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,2BAA2B,qBAAA,CAAsB;AAAA,GACnD;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeedbackActions.esm.js","sources":["../../src/hooks/useFeedbackActions.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { MessageProps } from '@patternfly/chatbot';\nimport { UserFeedbackProps } from '@patternfly/chatbot/dist/cjs/Message/UserFeedback/UserFeedback';\nimport { UserFeedbackCompleteProps } from '@patternfly/chatbot/dist/cjs/Message/UserFeedback/UserFeedbackComplete';\n\nimport { useCaptureFeedback } from '../hooks/useCaptureFeedback';\nimport { CaptureFeedback } from '../types';\nimport { Sentiment, useFeedbackState } from './useFeedbackState';\nimport { useFeedbackStatus } from './useFeedbackStatus';\nimport { useTranslation } from './useTranslation';\n\nexport const useFeedbackActions = <T extends MessageProps>(\n messages: T[],\n conversationId: string,\n isStreaming: boolean,\n): T[] => {\n const copyButtonRef = useRef<HTMLButtonElement>(null);\n const speakingButtonRef = useRef<HTMLButtonElement>(null);\n const currentSpeakingIdRef = useRef<string | null>(null);\n\n const { data: feedbackEnabled } = useFeedbackStatus();\n const { state, ...dispatch } = useFeedbackState();\n const { mutateAsync: captureFeedback } = useCaptureFeedback();\n const { t } = useTranslation();\n\n const createQuickResponses = useMemo(\n () => ({\n positive: [\n { id: '1', content: t('feedback.quickResponses.positive.helpful') },\n {\n id: '2',\n content: t('feedback.quickResponses.positive.easyToUnderstand'),\n },\n {\n id: '3',\n content: t('feedback.quickResponses.positive.resolvedIssue'),\n },\n ],\n negative: [\n { id: '1', content: t('feedback.quickResponses.negative.didntAnswer') },\n {\n id: '2',\n content: t('feedback.quickResponses.negative.hardToUnderstand'),\n },\n { id: '3', content: t('feedback.quickResponses.negative.notHelpful') },\n ],\n }),\n [t],\n );\n\n const getFeedbackForm = useCallback(\n (messageId: string, sentiment: 'positive' | 'negative') => ({\n key: `feedback-${sentiment}`,\n id: `feedback-${sentiment}-${messageId}`,\n hasTextArea: true,\n title: t('feedback.form.title'),\n textAreaPlaceholder: t('feedback.form.textAreaPlaceholder'),\n submitWord: t('feedback.form.submitWord'),\n quickResponses: createQuickResponses[sentiment],\n onSubmit: (\n quickResponse: string | undefined = '0',\n additionalFeedback: string | undefined,\n ) => {\n const quickIndex = Number(quickResponse) - 1;\n const quickText =\n quickResponse !== '0'\n ? createQuickResponses[sentiment]?.[quickIndex]?.content\n : undefined;\n\n let user_feedback = '';\n\n if (quickText && additionalFeedback) {\n user_feedback = `${quickText}\\nAdditional feedback: ${additionalFeedback}`;\n } else if (quickText) {\n user_feedback = quickText;\n } else if (additionalFeedback) {\n user_feedback = additionalFeedback;\n }\n\n const botAnswerId = Number(messageId.split('-').pop());\n const userQuestionId = botAnswerId - 1;\n\n const payload: CaptureFeedback = {\n conversation_id: conversationId,\n user_feedback,\n sentiment: sentiment === 'positive' ? 1 : -1,\n user_question: messages[userQuestionId].content || '',\n llm_response: messages[botAnswerId].content || '',\n };\n\n captureFeedback(payload).then(() => {\n dispatch.hideFeedbackForm(messageId, sentiment);\n dispatch.showCompletionForm(messageId, sentiment);\n dispatch.updateButtonState(messageId, {\n sentiment: sentiment,\n feedbackSubmitted: true,\n });\n\n setTimeout(() => {\n dispatch.hideCompletionForm(messageId, sentiment);\n }, 1000);\n });\n },\n\n // eslint-disable-next-line no-console\n onClose: () => {\n dispatch.hideFeedbackForm(messageId, sentiment);\n dispatch.resetButtonState(messageId);\n dispatch.updateButtonState(messageId, { sentiment: undefined });\n },\n focusOnLoad: true,\n }),\n [\n captureFeedback,\n conversationId,\n dispatch,\n messages,\n createQuickResponses,\n t,\n ],\n );\n\n const feedbackForms = useCallback(\n (messageId: string): { [key in Sentiment]: UserFeedbackProps } => ({\n positive: getFeedbackForm(messageId, 'positive'),\n negative: getFeedbackForm(messageId, 'negative'),\n }),\n [getFeedbackForm],\n );\n\n const getUserFeedbackComplete = useCallback(\n (\n messageId: string,\n sentiment: Sentiment,\n ): UserFeedbackCompleteProps | undefined => {\n const isVisible = state[messageId]?.completionForm?.[sentiment];\n if (!isVisible) return undefined;\n\n return {\n id: `feebback-completion-${sentiment}-${messageId}`,\n title: t('feedback.completion.title'),\n body: t('feedback.completion.body'),\n onClose: () => {\n dispatch.hideCompletionForm(messageId, sentiment);\n dispatch.resetButtonState(messageId);\n },\n };\n },\n [state, dispatch, t],\n );\n\n const scrollToFeedbackForm = useCallback(\n (messageId: string, sentiment: Sentiment) => {\n setTimeout(() => {\n const el = document.getElementById(\n `feedback-${sentiment}-${messageId}`,\n );\n if (el) {\n el.scrollIntoView({ behavior: 'auto', block: 'start' });\n el.focus();\n }\n }, 0);\n },\n [],\n );\n\n const speakMessage = useCallback(\n (messageId: string, content: string) => {\n if (window.speechSynthesis.speaking || window.speechSynthesis.pending) {\n window.speechSynthesis.cancel();\n\n if (\n currentSpeakingIdRef.current &&\n currentSpeakingIdRef.current !== messageId\n ) {\n dispatch.updateButtonState(currentSpeakingIdRef.current, {\n isSpeaking: false,\n });\n }\n }\n\n // Track the current SpeakingId\n currentSpeakingIdRef.current = messageId;\n\n const utterance = new SpeechSynthesisUtterance(content);\n\n utterance.onstart = () => {\n dispatch.updateButtonState(messageId, { isSpeaking: true });\n };\n\n utterance.onend = () => {\n dispatch.updateButtonState(messageId, { isSpeaking: false });\n currentSpeakingIdRef.current = null;\n };\n\n utterance.onerror = () => {\n dispatch.updateButtonState(messageId, { isSpeaking: false });\n currentSpeakingIdRef.current = null;\n };\n\n window.speechSynthesis.speak(utterance);\n },\n [dispatch],\n );\n\n const cancelSpeaking = useCallback(\n (messageId?: string) => {\n window.speechSynthesis.cancel();\n\n currentSpeakingIdRef.current = null;\n\n if (messageId) {\n // Cancel just this one message\n dispatch.updateButtonState(messageId, { isSpeaking: false });\n } else {\n // Cancel all messages\n Object.keys(state).forEach(id => {\n if (state[id].buttonState?.isSpeaking) {\n dispatch.updateButtonState(id, { isSpeaking: false });\n }\n });\n }\n setTimeout(() => {\n const el = document.getElementById(`listen-${messageId}`);\n if (el) {\n el.blur();\n }\n }, 10);\n },\n [state, dispatch],\n );\n\n useEffect(() => {\n return () => {\n // Stop any ongoing speech when component unmounts\n cancelSpeaking();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [conversationId]);\n\n return useMemo(() => {\n return feedbackEnabled\n ? messages.map((message, index) => {\n if (\n message.role === 'user' ||\n (isStreaming && messages.length - 1 === index)\n )\n return message;\n\n const messageId = `${conversationId}-${message.role}-${index}`;\n const { sentiment, copied, isSpeaking } =\n state[messageId]?.buttonState || {};\n const showFeedbackForm = state[messageId]?.feedbackForm?.[sentiment];\n const userFeedbackForm =\n showFeedbackForm && feedbackForms(messageId)[sentiment];\n\n const userFeedbackComplete = getUserFeedbackComplete(\n messageId,\n sentiment,\n );\n\n const createSentimentAction = (selected: Sentiment) => ({\n isClicked: sentiment === selected,\n onClick: () => {\n if (sentiment !== selected) {\n dispatch.toggleFeedbackForm(messageId, selected);\n dispatch.updateButtonState(messageId, { sentiment: selected });\n scrollToFeedbackForm(messageId, sentiment);\n }\n },\n tooltipContent:\n selected === 'positive'\n ? t('feedback.tooltips.goodResponse')\n : t('feedback.tooltips.badResponse'),\n 'aria-expanded': sentiment === selected,\n 'aria-controls': showFeedbackForm\n ? `feedback-${sentiment}-${messageId}`\n : `feebback-completion-${sentiment}-${messageId}`,\n });\n\n const copyAction = {\n isClicked: copied,\n ref: copyButtonRef,\n tooltipContent: copied\n ? t('feedback.tooltips.copied')\n : t('feedback.tooltips.copy'),\n onClick: async () => {\n await window.navigator.clipboard.writeText(\n message.content as string,\n );\n dispatch.updateButtonState(messageId, {\n copied: true,\n });\n\n setTimeout(() => {\n dispatch.updateButtonState(messageId, { copied: false });\n copyButtonRef?.current?.blur();\n }, 1000);\n },\n };\n\n const listenAction = {\n isClicked: isSpeaking,\n ref: speakingButtonRef,\n id: `listen-${messageId}`,\n tooltipContent: isSpeaking\n ? t('feedback.tooltips.listening')\n : t('feedback.tooltips.listen'),\n onClick: () => {\n const isCurrentlySpeaking =\n state[messageId]?.buttonState?.isSpeaking;\n\n if (isCurrentlySpeaking) {\n // Stop if it's already speaking this message\n cancelSpeaking(messageId);\n } else {\n cancelSpeaking();\n speakMessage(messageId, message.content as string);\n }\n },\n };\n\n return {\n ...message,\n userFeedbackForm,\n userFeedbackComplete,\n actions: {\n positive: createSentimentAction('positive'),\n negative: createSentimentAction('negative'),\n copy: copyAction,\n listen: listenAction,\n },\n };\n })\n : messages;\n }, [\n t,\n conversationId,\n messages,\n state,\n dispatch,\n isStreaming,\n speakMessage,\n feedbackForms,\n cancelSpeaking,\n feedbackEnabled,\n getUserFeedbackComplete,\n scrollToFeedbackForm,\n ]);\n};\n"],"names":[],"mappings":";;;;;;AA2BO,MAAM,kBAAA,GAAqB,CAChC,QAAA,EACA,cAAA,EACA,WAAA,KACQ;AACR,EAAA,MAAM,aAAA,GAAgB,OAA0B,IAAI,CAAA;AACpD,EAAA,MAAM,iBAAA,GAAoB,OAA0B,IAAI,CAAA;AACxD,EAAA,MAAM,oBAAA,GAAuB,OAAsB,IAAI,CAAA;AAEvD,EAAA,MAAM,EAAE,IAAA,EAAM,eAAA,EAAgB,GAAI,iBAAA,EAAkB;AACpD,EAAA,MAAM,EAAE,KAAA,EAAO,GAAG,QAAA,KAAa,gBAAA,EAAiB;AAChD,EAAA,MAAM,EAAE,WAAA,EAAa,eAAA,EAAgB,GAAI,kBAAA,EAAmB;AAC5D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAE7B,EAAA,MAAM,oBAAA,GAAuB,OAAA;AAAA,IAC3B,OAAO;AAAA,MACL,QAAA,EAAU;AAAA,QACR,EAAE,EAAA,EAAI,GAAA,EAAK,OAAA,EAAS,CAAA,CAAE,0CAA0C,CAAA,EAAE;AAAA,QAClE;AAAA,UACE,EAAA,EAAI,GAAA;AAAA,UACJ,OAAA,EAAS,EAAE,mDAAmD;AAAA,SAChE;AAAA,QACA;AAAA,UACE,EAAA,EAAI,GAAA;AAAA,UACJ,OAAA,EAAS,EAAE,gDAAgD;AAAA;AAC7D,OACF;AAAA,MACA,QAAA,EAAU;AA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AAA,UAC1C,IAAA,EAAM,UAAA;AAAA,UACN,MAAA,EAAQ;AAAA;AACV,OACF;AAAA,IACF,CAAC,CAAA,GACD,QAAA;AAAA,EACN,CAAA,EAAG;AAAA,IACD,CAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,cAAA;AAAA,IACA,eAAA;AAAA,IACA,uBAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"useFeedbackActions.esm.js","sources":["../../src/hooks/useFeedbackActions.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport {\n MessageProps,\n UserFeedbackCompleteProps,\n UserFeedbackProps,\n} from '@patternfly/chatbot';\n\nimport { useCaptureFeedback } from '../hooks/useCaptureFeedback';\nimport { CaptureFeedback } from '../types';\nimport { Sentiment, useFeedbackState } from './useFeedbackState';\nimport { useFeedbackStatus } from './useFeedbackStatus';\nimport { useTranslation } from './useTranslation';\n\nexport const useFeedbackActions = <T extends MessageProps>(\n messages: T[],\n conversationId: string,\n isStreaming: boolean,\n): T[] => {\n const copyButtonRef = useRef<HTMLButtonElement>(null);\n const speakingButtonRef = useRef<HTMLButtonElement>(null);\n const currentSpeakingIdRef = useRef<string | null>(null);\n\n const { data: feedbackEnabled } = useFeedbackStatus();\n const { state, ...dispatch } = useFeedbackState();\n const { mutateAsync: captureFeedback } = useCaptureFeedback();\n const { t } = useTranslation();\n\n const createQuickResponses = useMemo(\n () => ({\n positive: [\n { id: '1', content: t('feedback.quickResponses.positive.helpful') },\n {\n id: '2',\n content: t('feedback.quickResponses.positive.easyToUnderstand'),\n },\n {\n id: '3',\n content: t('feedback.quickResponses.positive.resolvedIssue'),\n },\n ],\n negative: [\n { id: '1', content: t('feedback.quickResponses.negative.didntAnswer') },\n {\n id: '2',\n content: t('feedback.quickResponses.negative.hardToUnderstand'),\n },\n { id: '3', content: t('feedback.quickResponses.negative.notHelpful') },\n ],\n }),\n [t],\n );\n\n const getFeedbackForm = useCallback(\n (messageId: string, sentiment: 'positive' | 'negative') => ({\n key: `feedback-${sentiment}`,\n id: `feedback-${sentiment}-${messageId}`,\n hasTextArea: true,\n title: t('feedback.form.title'),\n textAreaPlaceholder: t('feedback.form.textAreaPlaceholder'),\n submitWord: t('feedback.form.submitWord'),\n quickResponses: createQuickResponses[sentiment],\n onSubmit: (\n quickResponse: string | undefined = '0',\n additionalFeedback: string | undefined,\n ) => {\n const quickIndex = Number(quickResponse) - 1;\n const quickText =\n quickResponse !== '0'\n ? createQuickResponses[sentiment]?.[quickIndex]?.content\n : undefined;\n\n let user_feedback = '';\n\n if (quickText && additionalFeedback) {\n user_feedback = `${quickText}\\nAdditional feedback: ${additionalFeedback}`;\n } else if (quickText) {\n user_feedback = quickText;\n } else if (additionalFeedback) {\n user_feedback = additionalFeedback;\n }\n\n const botAnswerId = Number(messageId.split('-').pop());\n const userQuestionId = botAnswerId - 1;\n\n const payload: CaptureFeedback = {\n conversation_id: conversationId,\n user_feedback,\n sentiment: sentiment === 'positive' ? 1 : -1,\n user_question: messages[userQuestionId].content || '',\n llm_response: messages[botAnswerId].content || '',\n };\n\n captureFeedback(payload).then(() => {\n dispatch.hideFeedbackForm(messageId, sentiment);\n dispatch.showCompletionForm(messageId, sentiment);\n dispatch.updateButtonState(messageId, {\n sentiment: sentiment,\n feedbackSubmitted: true,\n });\n\n setTimeout(() => {\n dispatch.hideCompletionForm(messageId, sentiment);\n }, 1000);\n });\n },\n\n // eslint-disable-next-line no-console\n onClose: () => {\n dispatch.hideFeedbackForm(messageId, sentiment);\n dispatch.resetButtonState(messageId);\n dispatch.updateButtonState(messageId, { sentiment: undefined });\n },\n focusOnLoad: true,\n }),\n [\n captureFeedback,\n conversationId,\n dispatch,\n messages,\n createQuickResponses,\n t,\n ],\n );\n\n const feedbackForms = useCallback(\n (messageId: string): { [key in Sentiment]: UserFeedbackProps } => ({\n positive: getFeedbackForm(messageId, 'positive'),\n negative: getFeedbackForm(messageId, 'negative'),\n }),\n [getFeedbackForm],\n );\n\n const getUserFeedbackComplete = useCallback(\n (\n messageId: string,\n sentiment: Sentiment,\n ): UserFeedbackCompleteProps | undefined => {\n const isVisible = state[messageId]?.completionForm?.[sentiment];\n if (!isVisible) return undefined;\n\n return {\n id: `feebback-completion-${sentiment}-${messageId}`,\n title: t('feedback.completion.title'),\n body: t('feedback.completion.body'),\n onClose: () => {\n dispatch.hideCompletionForm(messageId, sentiment);\n dispatch.resetButtonState(messageId);\n },\n };\n },\n [state, dispatch, t],\n );\n\n const scrollToFeedbackForm = useCallback(\n (messageId: string, sentiment: Sentiment) => {\n setTimeout(() => {\n const el = document.getElementById(\n `feedback-${sentiment}-${messageId}`,\n );\n if (el) {\n el.scrollIntoView({ behavior: 'auto', block: 'start' });\n el.focus();\n }\n }, 0);\n },\n [],\n );\n\n const speakMessage = useCallback(\n (messageId: string, content: string) => {\n if (window.speechSynthesis.speaking || window.speechSynthesis.pending) {\n window.speechSynthesis.cancel();\n\n if (\n currentSpeakingIdRef.current &&\n currentSpeakingIdRef.current !== messageId\n ) {\n dispatch.updateButtonState(currentSpeakingIdRef.current, {\n isSpeaking: false,\n });\n }\n }\n\n // Track the current SpeakingId\n currentSpeakingIdRef.current = messageId;\n\n const utterance = new SpeechSynthesisUtterance(content);\n\n utterance.onstart = () => {\n dispatch.updateButtonState(messageId, { isSpeaking: true });\n };\n\n utterance.onend = () => {\n dispatch.updateButtonState(messageId, { isSpeaking: false });\n currentSpeakingIdRef.current = null;\n };\n\n utterance.onerror = () => {\n dispatch.updateButtonState(messageId, { isSpeaking: false });\n currentSpeakingIdRef.current = null;\n };\n\n window.speechSynthesis.speak(utterance);\n },\n [dispatch],\n );\n\n const cancelSpeaking = useCallback(\n (messageId?: string) => {\n window.speechSynthesis.cancel();\n\n currentSpeakingIdRef.current = null;\n\n if (messageId) {\n // Cancel just this one message\n dispatch.updateButtonState(messageId, { isSpeaking: false });\n } else {\n // Cancel all messages\n Object.keys(state).forEach(id => {\n if (state[id].buttonState?.isSpeaking) {\n dispatch.updateButtonState(id, { isSpeaking: false });\n }\n });\n }\n setTimeout(() => {\n const el = document.getElementById(`listen-${messageId}`);\n if (el) {\n el.blur();\n }\n }, 10);\n },\n [state, dispatch],\n );\n\n useEffect(() => {\n return () => {\n // Stop any ongoing speech when component unmounts\n cancelSpeaking();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [conversationId]);\n\n return useMemo(() => {\n return feedbackEnabled\n ? messages.map((message, index) => {\n if (\n message.role === 'user' ||\n (isStreaming && messages.length - 1 === index)\n )\n return message;\n\n const messageId = `${conversationId}-${message.role}-${index}`;\n const { sentiment, copied, isSpeaking } =\n state[messageId]?.buttonState || {};\n const showFeedbackForm = state[messageId]?.feedbackForm?.[sentiment];\n const userFeedbackForm =\n showFeedbackForm && feedbackForms(messageId)[sentiment];\n\n const userFeedbackComplete = getUserFeedbackComplete(\n messageId,\n sentiment,\n );\n\n const createSentimentAction = (selected: Sentiment) => ({\n isClicked: sentiment === selected,\n onClick: () => {\n if (sentiment !== selected) {\n dispatch.toggleFeedbackForm(messageId, selected);\n dispatch.updateButtonState(messageId, { sentiment: selected });\n scrollToFeedbackForm(messageId, sentiment);\n }\n },\n tooltipContent:\n selected === 'positive'\n ? t('feedback.tooltips.goodResponse')\n : t('feedback.tooltips.badResponse'),\n 'aria-expanded': sentiment === selected,\n 'aria-controls': showFeedbackForm\n ? `feedback-${sentiment}-${messageId}`\n : `feebback-completion-${sentiment}-${messageId}`,\n });\n\n const copyAction = {\n isClicked: copied,\n ref: copyButtonRef,\n tooltipContent: copied\n ? t('feedback.tooltips.copied')\n : t('feedback.tooltips.copy'),\n onClick: async () => {\n await window.navigator.clipboard.writeText(\n message.content as string,\n );\n dispatch.updateButtonState(messageId, {\n copied: true,\n });\n\n setTimeout(() => {\n dispatch.updateButtonState(messageId, { copied: false });\n copyButtonRef?.current?.blur();\n }, 1000);\n },\n };\n\n const listenAction = {\n isClicked: isSpeaking,\n ref: speakingButtonRef,\n id: `listen-${messageId}`,\n tooltipContent: isSpeaking\n ? t('feedback.tooltips.listening')\n : t('feedback.tooltips.listen'),\n onClick: () => {\n const isCurrentlySpeaking =\n state[messageId]?.buttonState?.isSpeaking;\n\n if (isCurrentlySpeaking) {\n // Stop if it's already speaking this message\n cancelSpeaking(messageId);\n } else {\n cancelSpeaking();\n speakMessage(messageId, message.content as string);\n }\n },\n };\n\n return {\n ...message,\n userFeedbackForm,\n userFeedbackComplete,\n actions: {\n positive: createSentimentAction('positive'),\n negative: createSentimentAction('negative'),\n copy: copyAction,\n listen: listenAction,\n },\n };\n })\n : messages;\n }, [\n t,\n conversationId,\n messages,\n state,\n dispatch,\n isStreaming,\n speakMessage,\n feedbackForms,\n cancelSpeaking,\n feedbackEnabled,\n getUserFeedbackComplete,\n scrollToFeedbackForm,\n ]);\n};\n"],"names":[],"mappings":";;;;;;AA6BO,MAAM,kBAAA,GAAqB,CAChC,QAAA,EACA,cAAA,EACA,WAAA,KACQ;AACR,EAAA,MAAM,aAAA,GAAgB,OAA0B,IAAI,CAAA;AACpD,EAAA,MAAM,iBAAA,GAAoB,OAA0B,IAAI,CAAA;AACxD,EAAA,MAAM,oBAAA,GAAuB,OAAsB,IAAI,CAAA;AAEvD,EAAA,MAAM,EAAE,IAAA,EAAM,eAAA,EAAgB,GAAI,iBAAA,EAAkB;AACpD,EAAA,MAAM,EAA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AA,CAAE,6BAA6B,CAAA,GAC/B,EAAE,0BAA0B,CAAA;AAAA,QAChC,SAAS,MAAM;AACb,UAAA,MAAM,mBAAA,GACJ,KAAA,CAAM,SAAS,CAAA,EAAG,WAAA,EAAa,UAAA;AAEjC,UAAA,IAAI,mBAAA,EAAqB;AAEvB,YAAA,cAAA,CAAe,SAAS,CAAA;AAAA,UAC1B,CAAA,MAAO;AACL,YAAA,cAAA,EAAe;AACf,YAAA,YAAA,CAAa,SAAA,EAAW,QAAQ,OAAiB,CAAA;AAAA,UACnD;AAAA,QACF;AAAA,OACF;AAEA,MAAA,OAAO;AAAA,QACL,GAAG,OAAA;AAAA,QACH,gBAAA;AAAA,QACA,oBAAA;AAAA,QACA,OAAA,EAAS;AAAA,UACP,QAAA,EAAU,sBAAsB,UAAU,CAAA;AAAA,UAC1C,QAAA,EAAU,sBAAsB,UAAU,CAAA;AAAA,UAC1C,IAAA,EAAM,UAAA;AAAA,UACN,MAAA,EAAQ;AAAA;AACV,OACF;AAAA,IACF,CAAC,CAAA,GACD,QAAA;AAAA,EACN,CAAA,EAAG;AAAA,IACD,CAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,cAAA;AAAA,IACA,eAAA;AAAA,IACA,uBAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
2
|
-
import {
|
|
2
|
+
import { iaChatPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';
|
|
3
3
|
|
|
4
4
|
const useLightspeedDeletePermission = () => {
|
|
5
5
|
const lightspeedDeletePermissionResult = usePermission({
|
|
6
|
-
permission:
|
|
6
|
+
permission: iaChatPermission
|
|
7
7
|
});
|
|
8
8
|
return lightspeedDeletePermissionResult;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLightspeedDeletePermission.esm.js","sources":["../../src/hooks/useLightspeedDeletePermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useLightspeedDeletePermission.esm.js","sources":["../../src/hooks/useLightspeedDeletePermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport { iaChatPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';\n\nexport const useLightspeedDeletePermission = () => {\n const lightspeedDeletePermissionResult = usePermission({\n permission: iaChatPermission,\n });\n\n return lightspeedDeletePermissionResult;\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,gCAAgC,MAAM;AACjD,EAAA,MAAM,mCAAmC,aAAA,CAAc;AAAA,IACrD,UAAA,EAAY;AAAA,GACb,CAAA;AAED,EAAA,OAAO,gCAAA;AACT;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
2
|
-
import {
|
|
2
|
+
import { iaChatPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';
|
|
3
3
|
|
|
4
4
|
const useLightspeedUpdatePermission = () => {
|
|
5
5
|
const lightspeedUpdatePermissionResult = usePermission({
|
|
6
|
-
permission:
|
|
6
|
+
permission: iaChatPermission
|
|
7
7
|
});
|
|
8
8
|
return lightspeedUpdatePermissionResult;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLightspeedUpdatePermission.esm.js","sources":["../../src/hooks/useLightspeedUpdatePermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useLightspeedUpdatePermission.esm.js","sources":["../../src/hooks/useLightspeedUpdatePermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport { iaChatPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';\n\nexport const useLightspeedUpdatePermission = () => {\n const lightspeedUpdatePermissionResult = usePermission({\n permission: iaChatPermission,\n });\n\n return lightspeedUpdatePermissionResult;\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,gCAAgC,MAAM;AACjD,EAAA,MAAM,mCAAmC,aAAA,CAAc;AAAA,IACrD,UAAA,EAAY;AAAA,GACb,CAAA;AAED,EAAA,OAAO,gCAAA;AACT;;;;"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
2
|
-
import {
|
|
2
|
+
import { iaChatPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';
|
|
3
3
|
|
|
4
4
|
const useLightspeedViewPermission = () => {
|
|
5
|
-
const
|
|
6
|
-
permission:
|
|
7
|
-
});
|
|
8
|
-
const canCreateChats = usePermission({
|
|
9
|
-
permission: iaChatUsePermission
|
|
5
|
+
const canUseChats = usePermission({
|
|
6
|
+
permission: iaChatPermission
|
|
10
7
|
});
|
|
11
8
|
return {
|
|
12
|
-
loading:
|
|
13
|
-
allowed:
|
|
14
|
-
|
|
15
|
-
iaChatUsePermissionName: iaChatUsePermission.name
|
|
9
|
+
loading: canUseChats.loading,
|
|
10
|
+
allowed: canUseChats.allowed,
|
|
11
|
+
iaChatPermissionName: iaChatPermission.name
|
|
16
12
|
};
|
|
17
13
|
};
|
|
18
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLightspeedViewPermission.esm.js","sources":["../../src/hooks/useLightspeedViewPermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useLightspeedViewPermission.esm.js","sources":["../../src/hooks/useLightspeedViewPermission.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport { iaChatPermission } from '@red-hat-developer-hub/backstage-plugin-intelligent-assistant-common';\n\nexport const useLightspeedViewPermission = (): {\n loading: boolean;\n allowed: boolean;\n iaChatPermissionName: string;\n} => {\n const canUseChats = usePermission({\n permission: iaChatPermission,\n });\n\n return {\n loading: canUseChats.loading,\n allowed: canUseChats.allowed,\n iaChatPermissionName: iaChatPermission.name,\n };\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,8BAA8B,MAItC;AACH,EAAA,MAAM,cAAc,aAAA,CAAc;AAAA,IAChC,UAAA,EAAY;AAAA,GACb,CAAA;AAED,EAAA,OAAO;AAAA,IACL,SAAS,WAAA,CAAY,OAAA;AAAA,IACrB,SAAS,WAAA,CAAY,OAAA;AAAA,IACrB,sBAAsB,gBAAA,CAAiB;AAAA,GACzC;AACF;;;;"}
|
package/dist/types.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SourcesCardProps } from '@patternfly/chatbot';\nimport { AlertProps } from '@patternfly/react-core';\n\nexport type Conversations = {\n [key: string]: {\n user: string;\n bot: string;\n model: string;\n loading: boolean;\n timestamp: string;\n botTimestamp: string;\n error?: AlertProps;\n };\n};\n\n/**\n * @public\n * Referenced document metadata\n */\nexport type ReferencedDocument = {\n doc_title: string;\n doc_url: string;\n doc_description?: string;\n};\n\n/**\n * @public\n * List of referenced documents\n */\nexport type ReferencedDocuments = ReferencedDocument[];\n\n/**\n * @public\n * LCS model type - embedding or llm\n */\nexport type LCSModelType = 'embedding' | 'llm';\n\n/**\n * @public\n * LCS model API model type\n */\nexport type LCSModelApiModelType = 'embedding' | 'llm';\n\n/**\n * @public\n * LCS Model interface\n */\nexport interface LCSModel {\n identifier: string;\n metadata: {\n embedding_dimension: number;\n };\n api_model_type: LCSModelApiModelType;\n provider_id: string;\n type: 'model';\n provider_resource_id: string;\n model_type: LCSModelType;\n}\nexport interface LCSConversation {\n provider: string;\n model: string;\n messages: BaseMessage[];\n started_at: string;\n completed_at: string;\n referenced_documents?: ReferencedDocuments;\n}\n\nexport interface LCSShield {\n identifier: string;\n provider_id: string;\n type: 'shield';\n params: {};\n provider_resource_id: string;\n}\n\n/**\n * @public\n * Base message interface for chat messages\n */\nexport interface BaseMessage {\n name: string;\n type: string;\n id: number;\n content: string;\n model: string;\n timestamp: string;\n sources?: SourcesCardProps;\n referenced_documents?: ReferencedDocuments;\n error?: AlertProps;\n}\n\n/**\n * @public\n * Conversation summary type\n */\nexport type ConversationSummary = {\n conversation_id: string;\n last_message_timestamp: number;\n topic_summary: string | null;\n};\n\nexport enum SupportedFileType {\n JSON = 'application/json',\n YAML = 'application/x-yaml',\n TEXT = 'text/plain',\n}\nexport interface FileContent {\n content: string;\n type: string;\n name: string;\n}\n\n/**\n * @public\n * Attachment type for file attachments in chat messages\n */\nexport type Attachment = {\n attachment_type: string;\n content_type: string;\n content: string;\n};\n\n/**\n * @public\n * List of conversation summaries\n */\nexport type ConversationList = ConversationSummary[];\n\nexport type SamplePrompt =\n | {\n title: string;\n message: string;\n }\n | {\n titleKey: string;\n messageKey: string;\n };\n\nexport type SamplePrompts = SamplePrompt[];\n\n/**\n * @public\n * Feedback capture payload for user feedback on AI responses\n */\nexport type CaptureFeedback = {\n conversation_id: string;\n user_question: string;\n llm_response: string;\n user_feedback: string;\n sentiment: number;\n};\n\n// Tool Calling Types\nexport interface ToolCall {\n id: number | string;\n toolName: string;\n description?: string;\n arguments: Record<string, any>;\n response?: string;\n startTime: number;\n endTime?: number;\n executionTime?: number; // in seconds\n isLoading: boolean;\n}\n\nexport interface ToolCallEvent {\n id: number | string;\n token?: string | { tool_name: string; arguments: Record<string, any> };\n name?: string;\n args?: Record<string, any>;\n arguments?: Record<string, any>;\n type?: string;\n}\n\nexport interface ToolResultEvent {\n id: number | string;\n token?: { tool_name: string; response: string };\n status?: string;\n content?: string;\n}\n\n/**\n * @public\n * Notebook session metadata from AI Notebooks API\n */\nexport type NotebookSessionMetadata = {\n category?: string;\n tags?: string[];\n project?: string;\n document_ids?: string[];\n conversation_id?: string;\n};\n\n/**\n * @public\n * Notebook session from AI Notebooks API\n */\nexport type NotebookSession = {\n session_id: string;\n user_id: string;\n name: string;\n description?: string;\n created_at: string;\n updated_at: string;\n document_count?: number;\n metadata?: NotebookSessionMetadata;\n};\n\n/**\n * @public\n * Supported file types for notebook document uploads\n */\nexport type NotebookDocumentSourceType =\n 'text' | 'pdf' | 'md' | 'json' | 'yaml' | 'log';\n\n/**\n * @public\n * Document within a notebook session\n */\nexport type SessionDocument = {\n document_id: string;\n title: string;\n session_id: string;\n user_id: string;\n source_type: NotebookDocumentSourceType;\n created_at: string;\n metadata?: Record<string, any>;\n};\n\n/**\n * @public\n * Response from the document upload endpoint (HTTP 202)\n */\nexport type UploadDocumentResponse = {\n status: 'processing';\n document_id: string;\n session_id: string;\n message: string;\n};\n\n/**\n * @public\n * Document processing status from the status polling endpoint\n */\nexport type DocumentStatus = {\n status: 'in_progress' | 'completed' | 'failed' | 'cancelled';\n document_id: string;\n session_id: string;\n error?: string;\n};\n\n/**\n * @public\n * Response wrapper for session creation\n */\nexport type SessionResponse = {\n status: 'success' | 'error';\n session?: NotebookSession;\n message?: string;\n error?: string;\n};\n\n/**\n * @public\n * Response wrapper for document list\n */\nexport type DocumentListResponse = {\n status: 'success' | 'error';\n session_id?: string;\n documents?: SessionDocument[];\n count?: number;\n error?: string;\n};\n"],"names":["SupportedFileType"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SourcesCardProps } from '@patternfly/chatbot';\nimport { AlertProps } from '@patternfly/react-core';\n\nexport type Conversations = {\n [key: string]: {\n user: string;\n bot: string;\n model: string;\n loading: boolean;\n timestamp: string;\n botTimestamp: string;\n error?: AlertProps;\n };\n};\n\n/**\n * @public\n * Referenced document metadata\n */\nexport type ReferencedDocument = {\n doc_title: string;\n doc_url: string;\n doc_description?: string;\n source?: string;\n};\n\n/**\n * @public\n * List of referenced documents\n */\nexport type ReferencedDocuments = ReferencedDocument[];\n\n/**\n * @public\n * LCS model type - embedding or llm\n */\nexport type LCSModelType = 'embedding' | 'llm';\n\n/**\n * @public\n * LCS model API model type\n */\nexport type LCSModelApiModelType = 'embedding' | 'llm';\n\n/**\n * @public\n * LCS Model interface\n */\nexport interface LCSModel {\n identifier: string;\n metadata: {\n embedding_dimension: number;\n };\n api_model_type: LCSModelApiModelType;\n provider_id: string;\n type: 'model';\n provider_resource_id: string;\n model_type: LCSModelType;\n}\nexport interface LCSConversation {\n provider: string;\n model: string;\n messages: BaseMessage[];\n started_at: string;\n completed_at: string;\n referenced_documents?: ReferencedDocuments;\n}\n\nexport interface LCSShield {\n identifier: string;\n provider_id: string;\n type: 'shield';\n params: {};\n provider_resource_id: string;\n}\n\n/**\n * @public\n * Base message interface for chat messages\n */\nexport interface BaseMessage {\n name: string;\n type: string;\n id: number;\n content: string;\n model: string;\n timestamp: string;\n sources?: SourcesCardProps;\n referenced_documents?: ReferencedDocuments;\n error?: AlertProps;\n}\n\n/**\n * @public\n * Conversation summary type\n */\nexport type ConversationSummary = {\n conversation_id: string;\n last_message_timestamp: number;\n topic_summary: string | null;\n};\n\nexport enum SupportedFileType {\n JSON = 'application/json',\n YAML = 'application/x-yaml',\n TEXT = 'text/plain',\n}\nexport interface FileContent {\n content: string;\n type: string;\n name: string;\n}\n\n/**\n * @public\n * Attachment type for file attachments in chat messages\n */\nexport type Attachment = {\n attachment_type: string;\n content_type: string;\n content: string;\n};\n\n/**\n * @public\n * List of conversation summaries\n */\nexport type ConversationList = ConversationSummary[];\n\nexport type SamplePrompt =\n | {\n title: string;\n message: string;\n }\n | {\n titleKey: string;\n messageKey: string;\n };\n\nexport type SamplePrompts = SamplePrompt[];\n\n/**\n * @public\n * Feedback capture payload for user feedback on AI responses\n */\nexport type CaptureFeedback = {\n conversation_id: string;\n user_question: string;\n llm_response: string;\n user_feedback: string;\n sentiment: number;\n};\n\n// Tool Calling Types\nexport interface ToolCall {\n id: number | string;\n toolName: string;\n description?: string;\n arguments: Record<string, any>;\n response?: string;\n startTime: number;\n endTime?: number;\n executionTime?: number; // in seconds\n isLoading: boolean;\n}\n\nexport interface ToolCallEvent {\n id: number | string;\n token?: string | { tool_name: string; arguments: Record<string, any> };\n name?: string;\n args?: Record<string, any>;\n arguments?: Record<string, any>;\n type?: string;\n}\n\nexport interface ToolResultEvent {\n id: number | string;\n token?: { tool_name: string; response: string };\n status?: string;\n content?: string;\n}\n\n/**\n * @public\n * Notebook session metadata from AI Notebooks API\n */\nexport type NotebookSessionMetadata = {\n category?: string;\n tags?: string[];\n project?: string;\n document_ids?: string[];\n conversation_id?: string;\n};\n\n/**\n * @public\n * Notebook session from AI Notebooks API\n */\nexport type NotebookSession = {\n session_id: string;\n user_id: string;\n name: string;\n description?: string;\n created_at: string;\n updated_at: string;\n document_count?: number;\n metadata?: NotebookSessionMetadata;\n};\n\n/**\n * @public\n * Supported file types for notebook document uploads\n */\nexport type NotebookDocumentSourceType =\n 'text' | 'pdf' | 'md' | 'json' | 'yaml' | 'log';\n\n/**\n * @public\n * Document within a notebook session\n */\nexport type SessionDocument = {\n document_id: string;\n title: string;\n session_id: string;\n user_id: string;\n source_type: NotebookDocumentSourceType;\n created_at: string;\n metadata?: Record<string, any>;\n};\n\n/**\n * @public\n * Response from the document upload endpoint (HTTP 202)\n */\nexport type UploadDocumentResponse = {\n status: 'processing';\n document_id: string;\n session_id: string;\n message: string;\n};\n\n/**\n * @public\n * Document processing status from the status polling endpoint\n */\nexport type DocumentStatus = {\n status: 'in_progress' | 'completed' | 'failed' | 'cancelled';\n document_id: string;\n session_id: string;\n error?: string;\n};\n\n/**\n * @public\n * Response wrapper for session creation\n */\nexport type SessionResponse = {\n status: 'success' | 'error';\n session?: NotebookSession;\n message?: string;\n error?: string;\n};\n\n/**\n * @public\n * Response wrapper for document list\n */\nexport type DocumentListResponse = {\n status: 'success' | 'error';\n session_id?: string;\n documents?: SessionDocument[];\n count?: number;\n error?: string;\n};\n"],"names":["SupportedFileType"],"mappings":"AAsHO,IAAK,iBAAA,qBAAAA,kBAAAA,KAAL;AACL,EAAAA,mBAAA,MAAA,CAAA,GAAO,kBAAA;AACP,EAAAA,mBAAA,MAAA,CAAA,GAAO,oBAAA;AACP,EAAAA,mBAAA,MAAA,CAAA,GAAO,YAAA;AAHG,EAAA,OAAAA,kBAAAA;AAAA,CAAA,EAAA,iBAAA,IAAA,EAAA;;;;"}
|
|
@@ -3,6 +3,7 @@ import { ChatbotFootnote } from '@patternfly/chatbot';
|
|
|
3
3
|
import { Spinner } from '@patternfly/react-core';
|
|
4
4
|
import { ThumbtackIcon } from '@patternfly/react-icons';
|
|
5
5
|
import { RhUiAiInfoIcon } from '@patternfly/react-icons/dist/esm/icons/rh-ui-ai-info-icon';
|
|
6
|
+
import { RagSourceLabel } from '../components/RagSourceLabel.esm.js';
|
|
6
7
|
|
|
7
8
|
const getFootnoteProps = (t) => ({
|
|
8
9
|
label: t?.("footer.accuracy.label") || "Always review AI generated content prior to use."
|
|
@@ -151,12 +152,18 @@ const transformDocumentsToSources = (referenced_documents) => {
|
|
|
151
152
|
return void 0;
|
|
152
153
|
}
|
|
153
154
|
return {
|
|
154
|
-
sources: referenced_documents.map(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
sources: referenced_documents.map(
|
|
156
|
+
(doc) => ({
|
|
157
|
+
body: doc.doc_description,
|
|
158
|
+
title: doc.doc_title,
|
|
159
|
+
link: doc?.doc_url,
|
|
160
|
+
isExternal: !!doc?.doc_url,
|
|
161
|
+
...doc.source ? {
|
|
162
|
+
headerContent: /* @__PURE__ */ jsx(RagSourceLabel, { source: doc.source }),
|
|
163
|
+
ragSource: doc.source
|
|
164
|
+
} : {}
|
|
165
|
+
})
|
|
166
|
+
)
|
|
160
167
|
};
|
|
161
168
|
};
|
|
162
169
|
const sortConversations = (messages, sortOption) => {
|