@stack-spot/ai-chat-widget 1.37.0-beta.1 → 2.0.0-betacitric.2
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 +1 -71
- package/dist/StackspotAIWidget.d.ts +6 -2
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +7 -8
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +13 -17
- package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
- package/dist/chat-interceptors/quick-commands.js +3 -9
- package/dist/chat-interceptors/quick-commands.js.map +1 -1
- package/dist/components/AdaptiveTextArea.d.ts +1 -1
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +1 -1
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/components/AgentCard/AgentCardCreate.d.ts.map +1 -1
- package/dist/components/AgentCard/AgentCardCreate.js +4 -5
- package/dist/components/AgentCard/AgentCardCreate.js.map +1 -1
- package/dist/components/AgentCard/index.d.ts.map +1 -1
- package/dist/components/AgentCard/index.js +5 -6
- package/dist/components/AgentCard/index.js.map +1 -1
- package/dist/components/ButtonFavorite.d.ts +8 -7
- package/dist/components/ButtonFavorite.d.ts.map +1 -1
- package/dist/components/ButtonFavorite.js +5 -14
- package/dist/components/ButtonFavorite.js.map +1 -1
- package/dist/components/Code.d.ts.map +1 -1
- package/dist/components/Code.js +11 -9
- package/dist/components/Code.js.map +1 -1
- package/dist/components/ComponentNavigator.d.ts.map +1 -1
- package/dist/components/ComponentNavigator.js +2 -4
- package/dist/components/ComponentNavigator.js.map +1 -1
- package/dist/components/FadingOverflow.d.ts.map +1 -1
- package/dist/components/FadingOverflow.js +3 -4
- package/dist/components/FadingOverflow.js.map +1 -1
- package/dist/components/FileDescription.d.ts +0 -1
- package/dist/components/FileDescription.d.ts.map +1 -1
- package/dist/components/FileDescription.js +3 -4
- package/dist/components/FileDescription.js.map +1 -1
- package/dist/components/HistoryList.js +1 -1
- package/dist/components/HistoryList.js.map +1 -1
- package/dist/components/ListResource.js +3 -3
- package/dist/components/ListResource.js.map +1 -1
- package/dist/components/Markdown.js +1 -1
- package/dist/components/Markdown.js.map +1 -1
- package/dist/components/Modal.d.ts.map +1 -1
- package/dist/components/Modal.js +2 -4
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/QuickStartButton.d.ts +2 -3
- package/dist/components/QuickStartButton.d.ts.map +1 -1
- package/dist/components/QuickStartButton.js +4 -3
- package/dist/components/QuickStartButton.js.map +1 -1
- package/dist/components/RightPanelForm.d.ts.map +1 -1
- package/dist/components/RightPanelForm.js +20 -13
- package/dist/components/RightPanelForm.js.map +1 -1
- package/dist/components/RightPanelTabs.d.ts +1 -4
- package/dist/components/RightPanelTabs.d.ts.map +1 -1
- package/dist/components/RightPanelTabs.js +4 -16
- package/dist/components/RightPanelTabs.js.map +1 -1
- package/dist/components/Selector/index.d.ts.map +1 -1
- package/dist/components/Selector/index.js +5 -8
- package/dist/components/Selector/index.js.map +1 -1
- package/dist/components/Selector/styled.d.ts.map +1 -1
- package/dist/components/Selector/styled.js +8 -5
- package/dist/components/Selector/styled.js.map +1 -1
- package/dist/components/StackedBadge.js +5 -5
- package/dist/components/StackedBadge.js.map +1 -1
- package/dist/components/TabManager.d.ts.map +1 -1
- package/dist/components/TabManager.js +8 -31
- package/dist/components/TabManager.js.map +1 -1
- package/dist/components/ToolBadge.d.ts +3 -8
- package/dist/components/ToolBadge.d.ts.map +1 -1
- package/dist/components/ToolBadge.js +21 -99
- package/dist/components/ToolBadge.js.map +1 -1
- package/dist/components/WorkspaceTabNavigator.d.ts.map +1 -1
- package/dist/components/WorkspaceTabNavigator.js +7 -9
- package/dist/components/WorkspaceTabNavigator.js.map +1 -1
- package/dist/components/form/DescribedCheckboxGroup.d.ts +24 -2
- package/dist/components/form/DescribedCheckboxGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedCheckboxGroup.js +46 -29
- package/dist/components/form/DescribedCheckboxGroup.js.map +1 -1
- package/dist/components/form/DescribedRadioGroup.d.ts +24 -4
- package/dist/components/form/DescribedRadioGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedRadioGroup.js +39 -18
- package/dist/components/form/DescribedRadioGroup.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/layout.css +1 -27
- package/dist/right-panel/DefaultPanel.d.ts.map +1 -1
- package/dist/right-panel/DefaultPanel.js +2 -4
- package/dist/right-panel/DefaultPanel.js.map +1 -1
- package/dist/state/ChatEntry.d.ts +3 -4
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/constants.js +2 -2
- package/dist/state/constants.js.map +1 -1
- package/dist/types.d.ts +7 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tools.d.ts +1 -2
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +1 -12
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/upload/FileUpload.d.ts.map +1 -1
- package/dist/utils/upload/FileUpload.js +2 -1
- package/dist/utils/upload/FileUpload.js.map +1 -1
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
- package/dist/views/Agents/AgentDescription.js +5 -6
- package/dist/views/Agents/AgentDescription.js.map +1 -1
- package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
- package/dist/views/Agents/AgentsPanel.js +7 -7
- package/dist/views/Agents/AgentsPanel.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +29 -28
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/Chat/AgentInfo.d.ts.map +1 -1
- package/dist/views/Chat/AgentInfo.js +3 -5
- package/dist/views/Chat/AgentInfo.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +28 -36
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts.map +1 -1
- package/dist/views/Chat/StepsList.js +10 -10
- package/dist/views/Chat/StepsList.js.map +1 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +8 -2
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.js +7 -14
- package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
- package/dist/views/ChatHistory/index.js +1 -1
- package/dist/views/ChatHistory/index.js.map +1 -1
- package/dist/views/ChatHistory/styled.d.ts.map +1 -1
- package/dist/views/ChatHistory/styled.js +3 -5
- package/dist/views/ChatHistory/styled.js.map +1 -1
- package/dist/views/ChatTabSelection.d.ts +6 -1
- package/dist/views/ChatTabSelection.d.ts.map +1 -1
- package/dist/views/ChatTabSelection.js +12 -7
- package/dist/views/ChatTabSelection.js.map +1 -1
- package/dist/views/Editor.d.ts.map +1 -1
- package/dist/views/Editor.js +6 -12
- package/dist/views/Editor.js.map +1 -1
- package/dist/views/Home/BuiltInAgent.d.ts.map +1 -1
- package/dist/views/Home/BuiltInAgent.js +2 -3
- package/dist/views/Home/BuiltInAgent.js.map +1 -1
- package/dist/views/Home/CustomAgent.js +3 -3
- package/dist/views/Home/CustomAgent.js.map +1 -1
- package/dist/views/Home/index.js +2 -2
- package/dist/views/Home/index.js.map +1 -1
- package/dist/views/Home/styled.d.ts.map +1 -1
- package/dist/views/Home/styled.js +21 -22
- package/dist/views/Home/styled.js.map +1 -1
- package/dist/views/KSDocument.d.ts.map +1 -1
- package/dist/views/KSDocument.js +3 -4
- package/dist/views/KSDocument.js.map +1 -1
- package/dist/views/KnowledgeSources.d.ts.map +1 -1
- package/dist/views/KnowledgeSources.js +14 -36
- package/dist/views/KnowledgeSources.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +7 -5
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.d.ts.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.js +4 -5
- package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
- package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -1
- package/dist/views/MessageInput/ButtonBar.js +2 -4
- package/dist/views/MessageInput/ButtonBar.js.map +1 -1
- package/dist/views/MessageInput/ContextBar.d.ts.map +1 -1
- package/dist/views/MessageInput/ContextBar.js +3 -6
- package/dist/views/MessageInput/ContextBar.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +2 -2
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
- package/dist/views/MessageInput/SelectContent.d.ts.map +1 -1
- package/dist/views/MessageInput/SelectContent.js +30 -35
- package/dist/views/MessageInput/SelectContent.js.map +1 -1
- package/dist/views/MessageInput/UploadBar.d.ts.map +1 -1
- package/dist/views/MessageInput/UploadBar.js +2 -29
- package/dist/views/MessageInput/UploadBar.js.map +1 -1
- package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +1 -1
- package/dist/views/MessageInput/UploadDragNDrop.js +2 -3
- package/dist/views/MessageInput/UploadDragNDrop.js.map +1 -1
- package/dist/views/MessageInput/dictionary.d.ts +1 -1
- package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
- package/dist/views/MessageInput/dictionary.js +0 -4
- package/dist/views/MessageInput/dictionary.js.map +1 -1
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +3 -4
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/MessageInput/styled.d.ts +1 -3
- package/dist/views/MessageInput/styled.d.ts.map +1 -1
- package/dist/views/MessageInput/styled.js +11 -27
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/dist/views/MinimizedHeader.d.ts.map +1 -1
- package/dist/views/MinimizedHeader.js +2 -4
- package/dist/views/MinimizedHeader.js.map +1 -1
- package/dist/views/Stacks.d.ts.map +1 -1
- package/dist/views/Stacks.js +23 -28
- package/dist/views/Stacks.js.map +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.d.ts.map +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.js +3 -3
- package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -1
- package/dist/views/Steps/StepModal.d.ts.map +1 -1
- package/dist/views/Steps/StepModal.js +4 -6
- package/dist/views/Steps/StepModal.js.map +1 -1
- package/dist/views/Steps/dictionary.d.ts +1 -1
- package/dist/views/Steps/index.d.ts.map +1 -1
- package/dist/views/Steps/index.js +3 -4
- package/dist/views/Steps/index.js.map +1 -1
- package/dist/views/Steps/utils.d.ts +2 -1
- package/dist/views/Steps/utils.d.ts.map +1 -1
- package/dist/views/Steps/utils.js +8 -8
- package/dist/views/Steps/utils.js.map +1 -1
- package/dist/views/Tools.js +2 -4
- package/dist/views/Tools.js.map +1 -1
- package/dist/views/Workspaces/WorkspacesTab.d.ts.map +1 -1
- package/dist/views/Workspaces/WorkspacesTab.js +7 -10
- package/dist/views/Workspaces/WorkspacesTab.js.map +1 -1
- package/dist/views/Workspaces/index.js +4 -2
- package/dist/views/Workspaces/index.js.map +1 -1
- package/package.json +12 -13
- package/src/StackspotAIWidget.tsx +36 -34
- package/src/app-metadata.json +13 -17
- package/src/chat-interceptors/quick-commands.ts +5 -11
- package/src/components/AdaptiveTextArea.tsx +1 -1
- package/src/components/AgentCard/AgentCardCreate.tsx +4 -7
- package/src/components/AgentCard/index.tsx +7 -7
- package/src/components/ButtonFavorite.tsx +20 -47
- package/src/components/Code.tsx +31 -36
- package/src/components/ComponentNavigator.tsx +4 -8
- package/src/components/FadingOverflow.tsx +6 -7
- package/src/components/FileDescription.tsx +14 -11
- package/src/components/HistoryList.tsx +1 -1
- package/src/components/ListResource.tsx +5 -5
- package/src/components/Markdown.tsx +1 -1
- package/src/components/Modal.tsx +2 -4
- package/src/components/QuickStartButton.tsx +5 -4
- package/src/components/RightPanelForm.tsx +20 -13
- package/src/components/RightPanelTabs.tsx +4 -32
- package/src/components/Selector/index.tsx +17 -13
- package/src/components/Selector/styled.ts +8 -5
- package/src/components/StackedBadge.tsx +5 -5
- package/src/components/TabManager.tsx +28 -54
- package/src/components/ToolBadge.tsx +39 -129
- package/src/components/WorkspaceTabNavigator.tsx +22 -25
- package/src/components/form/DescribedCheckboxGroup.tsx +90 -65
- package/src/components/form/DescribedRadioGroup.tsx +79 -46
- package/src/index.ts +1 -2
- package/src/layout.css +1 -27
- package/src/right-panel/DefaultPanel.tsx +3 -7
- package/src/state/ChatEntry.ts +3 -4
- package/src/state/constants.ts +2 -2
- package/src/types.ts +8 -3
- package/src/utils/tools.ts +2 -23
- package/src/utils/upload/FileUpload.ts +2 -1
- package/src/views/Agents/AgentDescription.tsx +6 -7
- package/src/views/Agents/AgentsPanel.tsx +11 -12
- package/src/views/Agents/AgentsTab.tsx +37 -56
- package/src/views/Chat/AgentInfo.tsx +7 -6
- package/src/views/Chat/ChatMessage.tsx +109 -118
- package/src/views/Chat/StepsList.tsx +10 -11
- package/src/views/Chat/styled.ts +8 -2
- package/src/views/ChatHistory/HistoryItem.tsx +12 -19
- package/src/views/ChatHistory/index.tsx +1 -1
- package/src/views/ChatHistory/styled.ts +3 -5
- package/src/views/ChatTabSelection.tsx +17 -9
- package/src/views/Editor.tsx +9 -14
- package/src/views/Home/BuiltInAgent.tsx +7 -8
- package/src/views/Home/CustomAgent.tsx +3 -3
- package/src/views/Home/index.tsx +2 -2
- package/src/views/Home/styled.ts +21 -22
- package/src/views/KSDocument.tsx +7 -8
- package/src/views/KnowledgeSources.tsx +24 -66
- package/src/views/MessageInput/AgentSelector.tsx +10 -8
- package/src/views/MessageInput/ButtonAgent.tsx +24 -12
- package/src/views/MessageInput/ButtonBar.tsx +25 -21
- package/src/views/MessageInput/ContextBar.tsx +17 -14
- package/src/views/MessageInput/QuickCommandSelector.tsx +2 -2
- package/src/views/MessageInput/SelectContent.tsx +39 -68
- package/src/views/MessageInput/UploadBar.tsx +2 -40
- package/src/views/MessageInput/UploadDragNDrop.tsx +2 -5
- package/src/views/MessageInput/dictionary.ts +0 -4
- package/src/views/MessageInput/index.tsx +5 -7
- package/src/views/MessageInput/styled.ts +12 -28
- package/src/views/MinimizedHeader.tsx +4 -7
- package/src/views/Stacks.tsx +31 -54
- package/src/views/Steps/FlowChart/NodeStep.tsx +6 -4
- package/src/views/Steps/StepModal.tsx +14 -18
- package/src/views/Steps/index.tsx +4 -5
- package/src/views/Steps/utils.tsx +9 -9
- package/src/views/Tools.tsx +12 -19
- package/src/views/Workspaces/WorkspacesTab.tsx +17 -21
- package/src/views/Workspaces/index.tsx +4 -2
- package/dist/components/Accordion.d.ts +0 -20
- package/dist/components/Accordion.d.ts.map +0 -1
- package/dist/components/Accordion.js +0 -51
- package/dist/components/Accordion.js.map +0 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts +0 -33
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.js +0 -52
- package/dist/components/FallbackBoundary/ErrorBoundary.js.map +0 -1
- package/dist/components/FallbackBoundary/Loading.d.ts +0 -2
- package/dist/components/FallbackBoundary/Loading.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/Loading.js +0 -12
- package/dist/components/FallbackBoundary/Loading.js.map +0 -1
- package/dist/components/FallbackBoundary/index.d.ts +0 -17
- package/dist/components/FallbackBoundary/index.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/index.js +0 -9
- package/dist/components/FallbackBoundary/index.js.map +0 -1
- package/dist/components/IconInput.d.ts +0 -10
- package/dist/components/IconInput.d.ts.map +0 -1
- package/dist/components/IconInput.js +0 -61
- package/dist/components/IconInput.js.map +0 -1
- package/dist/components/OverlayMenu.d.ts +0 -21
- package/dist/components/OverlayMenu.d.ts.map +0 -1
- package/dist/components/OverlayMenu.js +0 -79
- package/dist/components/OverlayMenu.js.map +0 -1
- package/dist/components/ProgressBar.d.ts +0 -37
- package/dist/components/ProgressBar.d.ts.map +0 -1
- package/dist/components/ProgressBar.js +0 -131
- package/dist/components/ProgressBar.js.map +0 -1
- package/dist/components/Tooltip/Tooltip.d.ts +0 -37
- package/dist/components/Tooltip/Tooltip.d.ts.map +0 -1
- package/dist/components/Tooltip/Tooltip.js +0 -30
- package/dist/components/Tooltip/Tooltip.js.map +0 -1
- package/dist/components/Tooltip/TooltipAPI.d.ts +0 -29
- package/dist/components/Tooltip/TooltipAPI.d.ts.map +0 -1
- package/dist/components/Tooltip/TooltipAPI.js +0 -107
- package/dist/components/Tooltip/TooltipAPI.js.map +0 -1
- package/dist/components/Tooltip/context.d.ts +0 -5
- package/dist/components/Tooltip/context.d.ts.map +0 -1
- package/dist/components/Tooltip/context.js +0 -18
- package/dist/components/Tooltip/context.js.map +0 -1
- package/dist/components/Tooltip/index.d.ts +0 -3
- package/dist/components/Tooltip/index.d.ts.map +0 -1
- package/dist/components/Tooltip/index.js +0 -3
- package/dist/components/Tooltip/index.js.map +0 -1
- package/dist/components/Tooltip/style.d.ts +0 -4
- package/dist/components/Tooltip/style.d.ts.map +0 -1
- package/dist/components/Tooltip/style.js +0 -22
- package/dist/components/Tooltip/style.js.map +0 -1
- package/dist/components/Tooltip/types.d.ts +0 -27
- package/dist/components/Tooltip/types.d.ts.map +0 -1
- package/dist/components/Tooltip/types.js +0 -2
- package/dist/components/Tooltip/types.js.map +0 -1
- package/src/components/Accordion.tsx +0 -75
- package/src/components/FallbackBoundary/ErrorBoundary.tsx +0 -71
- package/src/components/FallbackBoundary/Loading.tsx +0 -14
- package/src/components/FallbackBoundary/index.tsx +0 -26
- package/src/components/IconInput.tsx +0 -73
- package/src/components/OverlayMenu.tsx +0 -133
- package/src/components/ProgressBar.tsx +0 -183
- package/src/components/Tooltip/Tooltip.tsx +0 -78
- package/src/components/Tooltip/TooltipAPI.ts +0 -101
- package/src/components/Tooltip/context.tsx +0 -24
- package/src/components/Tooltip/index.ts +0 -2
- package/src/components/Tooltip/style.tsx +0 -24
- package/src/components/Tooltip/types.ts +0 -28
|
@@ -1,52 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { Accordion, FieldGroup, ImageBox, Input, RadioGroup, Row, Text, useRadioGroupControls } from '@stack-spot/citric-react'
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
4
|
+
import { ButtonFavorite, Favorite } from '../ButtonFavorite'
|
|
5
|
+
|
|
6
|
+
interface Props<T> {
|
|
7
|
+
initialValue?: T,
|
|
8
|
+
options: T[],
|
|
9
|
+
/**
|
|
10
|
+
* Must return the data needed by the component, given the option.
|
|
11
|
+
* @param option
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
data: (option: T) => { name: string, description: React.ReactNode, image?: React.ReactElement } & Favorite<any>,
|
|
15
|
+
emptyResults: React.ReactNode,
|
|
16
|
+
emptyDataset: React.ReactNode,
|
|
17
|
+
onChange?: (value: T | undefined) => void,
|
|
18
|
+
}
|
|
7
19
|
|
|
8
20
|
/**
|
|
9
|
-
* Renders a radio
|
|
10
|
-
* The description in placed under the label and
|
|
21
|
+
* Renders a radio group where each option has a label and a description.
|
|
22
|
+
* The description in placed under the label and checkbox as an accordion.
|
|
23
|
+
*
|
|
24
|
+
* Also renders a search input.
|
|
11
25
|
*/
|
|
12
|
-
export function DescribedRadioGroup<T>(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
options,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
optionClassName,
|
|
22
|
-
optionStyle,
|
|
23
|
-
value,
|
|
24
|
-
className,
|
|
25
|
-
style }: RadioProps<T>,
|
|
26
|
-
) {
|
|
27
|
-
const items = useMemo(() => options.map((option) => {
|
|
28
|
-
const label = renderLabel(option)
|
|
29
|
-
const description = renderDescription(option)
|
|
26
|
+
export function DescribedRadioGroup<T>({ initialValue, options: opt, data, emptyDataset, emptyResults, onChange }: Props<T>) {
|
|
27
|
+
const [options, setOptions] = useState(opt)
|
|
28
|
+
const controls = useRadioGroupControls({
|
|
29
|
+
initialValue,
|
|
30
|
+
options,
|
|
31
|
+
applyFilter: (filter, o) => data(o).name.toLocaleLowerCase().includes(filter.toLocaleLowerCase()),
|
|
32
|
+
renderKey: o => data(o).idOrSlug,
|
|
33
|
+
onChange,
|
|
34
|
+
})
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{typeof label === 'string' ? <Text>{label}</Text> : label}
|
|
35
|
-
</label>
|
|
36
|
-
)
|
|
37
|
-
return (
|
|
38
|
-
<li key={keygen(option)} className={listToClass(['radio-group-item', optionClassName?.(option)])} style={optionStyle?.(option)}>
|
|
39
|
-
{renderBeforeElement?.(option)}
|
|
40
|
-
<Accordion header={header}>
|
|
41
|
-
{typeof description === 'string'
|
|
42
|
-
? <Text appearance="microtext1" colorScheme="light.700">{description}</Text>
|
|
43
|
-
: description as any
|
|
44
|
-
}
|
|
45
|
-
</Accordion>
|
|
46
|
-
{renderAfterElement?.(option)}
|
|
47
|
-
</li>
|
|
48
|
-
)
|
|
49
|
-
}), [options, value])
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (controls.value === undefined && initialValue !== undefined) controls.setValue(initialValue)
|
|
38
|
+
}, [initialValue])
|
|
50
39
|
|
|
51
|
-
return
|
|
40
|
+
return options.length ? <>
|
|
41
|
+
<FieldGroup fullWidth>
|
|
42
|
+
<Icon icon="Search" />
|
|
43
|
+
<Input type="search" value={controls.filter} onChange={controls.setFilter} />
|
|
44
|
+
</FieldGroup>
|
|
45
|
+
{controls.options.length ? <RadioGroup
|
|
46
|
+
options={controls.options}
|
|
47
|
+
value={controls.value}
|
|
48
|
+
onChange={controls.setValue}
|
|
49
|
+
renderKey={controls.renderKey}
|
|
50
|
+
className="option-list"
|
|
51
|
+
renderItem={(radio, o) => {
|
|
52
|
+
const { description, idOrSlug, name, image, listFavorites, onAddFavorite, onRemoveFavorite } = data(o)
|
|
53
|
+
return (
|
|
54
|
+
<Row className={controls.isUnfilteredButChecked(o) ? 'filtered-out' : ''}>
|
|
55
|
+
<Accordion
|
|
56
|
+
header={btn => <>
|
|
57
|
+
{radio}
|
|
58
|
+
{image && <ImageBox size="xs" style={{ fontSize: '16px' }}>{image}</ImageBox>}
|
|
59
|
+
<Text>{name}</Text>{btn}</>
|
|
60
|
+
}
|
|
61
|
+
appearance="card"
|
|
62
|
+
maxHeight={100}
|
|
63
|
+
>
|
|
64
|
+
{typeof description === 'string' ? <Text appearance="microtext1" color="light.700">{description}</Text> : description}
|
|
65
|
+
</Accordion>
|
|
66
|
+
{onAddFavorite && <ButtonFavorite favorite={{
|
|
67
|
+
idOrSlug: idOrSlug,
|
|
68
|
+
listFavorites,
|
|
69
|
+
onAddFavorite: async (...args) => {
|
|
70
|
+
const res = await onAddFavorite(...args)
|
|
71
|
+
setOptions([...options]) // forces options re-rendering
|
|
72
|
+
return res
|
|
73
|
+
},
|
|
74
|
+
onRemoveFavorite: async (...args) => {
|
|
75
|
+
const res = await onRemoveFavorite?.(...args)
|
|
76
|
+
setOptions([...options]) // forces options re-rendering
|
|
77
|
+
return res ?? false
|
|
78
|
+
},
|
|
79
|
+
}} />}
|
|
80
|
+
</Row>
|
|
81
|
+
)
|
|
82
|
+
}}
|
|
83
|
+
/> : emptyResults}
|
|
84
|
+
</> : emptyDataset
|
|
52
85
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* Attention: in order for the package "page" to work without linking the lib, we must export types separately, using the "type" keyword */
|
|
2
2
|
|
|
3
|
-
export { ProgressBar } from './components/ProgressBar'
|
|
4
3
|
export { QuickStartButton } from './components/QuickStartButton'
|
|
5
4
|
export { AIWidgetProvider } from './context/AIWidgetProvider'
|
|
6
5
|
export * from './context/hooks'
|
|
@@ -16,5 +15,5 @@ export { acceptedFileTypes } from './state/constants'
|
|
|
16
15
|
export { ObservableState } from './state/ObservableState'
|
|
17
16
|
export type { Labeled, LabeledAgent, LabeledWithImage } from './state/types'
|
|
18
17
|
export { WidgetState } from './state/WidgetState'
|
|
18
|
+
export type { ButtonAction } from './types'
|
|
19
19
|
export { defaultLanguage, languages } from './utils/programming-languages'
|
|
20
|
-
|
package/src/layout.css
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
@font-face {
|
|
2
|
-
font-family: "San Francisco";
|
|
3
|
-
font-weight: 400;
|
|
4
|
-
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff");
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/* Scroll bars */
|
|
8
|
-
|
|
9
|
-
::-webkit-scrollbar-track {
|
|
10
|
-
background-color: transparent;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
::-webkit-scrollbar {
|
|
14
|
-
width: 0.25rem;
|
|
15
|
-
height: 0.5rem;
|
|
16
|
-
background-color: transparent;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
::-webkit-scrollbar-thumb {
|
|
20
|
-
background-color: var(--light-600);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
::-webkit-scrollbar-corner {
|
|
24
|
-
background-color: transparent;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
1
|
/* Classes */
|
|
28
2
|
|
|
29
3
|
.ai-chat-widget {
|
|
@@ -209,4 +183,4 @@
|
|
|
209
183
|
z-index: 9999;
|
|
210
184
|
pointer-events: auto;
|
|
211
185
|
color: var(--light-contrastText)
|
|
212
|
-
}
|
|
186
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Text } from '@citric
|
|
2
|
-
import { Times } from '@citric/icons'
|
|
3
|
-
import { IconButton } from '@citric/ui'
|
|
1
|
+
import { IconButton, Text } from '@stack-spot/citric-react'
|
|
4
2
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
5
3
|
import { styled } from 'styled-components'
|
|
6
4
|
import { WithChildren } from '../types'
|
|
@@ -51,11 +49,9 @@ export const DefaultPanel = ({ description, onClose, title, children }: Props) =
|
|
|
51
49
|
<header>
|
|
52
50
|
<div className="title">
|
|
53
51
|
{typeof title === 'string' ? <Text appearance="h5">{title}</Text> : title}
|
|
54
|
-
{typeof description === 'string' ? <Text
|
|
52
|
+
{typeof description === 'string' ? <Text color="light.700">{description}</Text> : description}
|
|
55
53
|
</div>
|
|
56
|
-
<IconButton title={t.close} aria-label={t.close} onClick={onClose}
|
|
57
|
-
<Times />
|
|
58
|
-
</IconButton>
|
|
54
|
+
<IconButton icon="Times" title={t.close} aria-label={t.close} onClick={onClose} />
|
|
59
55
|
</header>
|
|
60
56
|
<article>{children}</article>
|
|
61
57
|
</PanelBox>
|
package/src/state/ChatEntry.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { OneOfColorSchemes } from '@citric/core'
|
|
2
1
|
import { ChatStep } from '@stack-spot/portal-network'
|
|
3
|
-
import { ColorPaletteName } from '@stack-spot/portal-theme'
|
|
2
|
+
import { ColorPaletteName, ColorSchemeName } from '@stack-spot/portal-theme'
|
|
4
3
|
import { pull } from 'lodash'
|
|
5
4
|
import { LabeledAgent } from './types'
|
|
6
5
|
|
|
@@ -32,7 +31,7 @@ export interface ChatAction extends SerializableAction {
|
|
|
32
31
|
/**
|
|
33
32
|
* @default inverse
|
|
34
33
|
*/
|
|
35
|
-
colorScheme?:
|
|
34
|
+
colorScheme?: ColorSchemeName,
|
|
36
35
|
/**
|
|
37
36
|
* @default false
|
|
38
37
|
*/
|
|
@@ -150,7 +149,7 @@ export interface TextChatEntry {
|
|
|
150
149
|
/*
|
|
151
150
|
* Options for radio, checkbox or button type.
|
|
152
151
|
*/
|
|
153
|
-
options?: { color?:
|
|
152
|
+
options?: { color?: ColorSchemeName, label: string, value?: string, hasInput?: boolean}[],
|
|
154
153
|
/**
|
|
155
154
|
* Name to be used in input type fields.
|
|
156
155
|
*/
|
package/src/state/constants.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FileSize } from './types'
|
|
2
2
|
|
|
3
3
|
export const acceptedFileTypes = [
|
|
4
|
-
'json', 'yaml', 'txt', 'md', 'json', 'yaml', 'pdf', /*'xls'
|
|
4
|
+
'json', 'yaml', 'txt', 'md', 'json', 'yaml', 'pdf', /*'xls', 'xlsx',*/ 'csv', 'cbl', 'cpp', 'cxx', 'cc', 'c', 'hpp', 'hxx', 'hh', 'h',
|
|
5
5
|
'cs', 'go', 'html', 'htm', 'kt', 'kts', 'md', 'php', 'proto', 'py', 'java', 'js', 'jsx', 'ts', 'tsx', 'rst', 'rb', 'rs', 'scala', 'swift',
|
|
6
6
|
'sql', 'yaml', 'yml', 'tf', 'sh', 'ps1', 'psd1', 'psm1', 'bat', 'cmd', 'rego', 'f', 'for', 'r', 'pl', 'vb', 'dart', 'hs', 'lua',
|
|
7
|
-
'asm', 'groovy', 'gvy', 'gy', 'mat', 'clj', 'lisp', 'm', 'cls', 'css', 'scss', 'json', 'jpg', 'jpeg', 'png',
|
|
7
|
+
'asm', 'groovy', 'gvy', 'gy', 'mat', 'clj', 'lisp', 'm', 'cls', 'css', 'scss', 'json', 'jpg', 'jpeg', 'png',
|
|
8
8
|
]
|
|
9
9
|
|
|
10
10
|
export const maxFileSize: FileSize = { value: 10, unit: 'MB' }
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { WithIcon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { BaseIconBoxProps } from '@stack-spot/citric-react'
|
|
1
3
|
import { WithStyle } from '@stack-spot/portal-theme'
|
|
2
4
|
|
|
3
5
|
export interface WithChildren<T = React.ReactNode> {
|
|
@@ -6,13 +8,16 @@ export interface WithChildren<T = React.ReactNode> {
|
|
|
6
8
|
|
|
7
9
|
export type PropsOf<T extends React.FunctionComponent> = T extends React.FunctionComponent<infer P> ? P : never
|
|
8
10
|
|
|
9
|
-
export
|
|
10
|
-
icon?: React.ReactElement,
|
|
11
|
+
export type ButtonAction = {
|
|
11
12
|
color?: string,
|
|
12
13
|
label?: string,
|
|
13
14
|
ariaLabel?: string,
|
|
15
|
+
title?: string,
|
|
14
16
|
onClick: () => any,
|
|
15
|
-
|
|
17
|
+
appearance?: BaseIconBoxProps<any, any>['appearance'],
|
|
18
|
+
size?: BaseIconBoxProps<any, any>['size'],
|
|
19
|
+
} & WithStyle & Partial<WithIcon>
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
export interface MinimizedActions {
|
|
18
23
|
/**
|
package/src/utils/tools.ts
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
import { BuiltinToolkitResponse, BuiltinToolResponse } from '@stack-spot/portal-network/api/agent'
|
|
2
|
-
import { CustomToolkitDto } from '@stack-spot/portal-network/api/agent-tools'
|
|
3
2
|
import { keyBy } from 'lodash'
|
|
4
3
|
|
|
5
4
|
export type ToolWithImage = BuiltinToolResponse & { id: string, image?: string }
|
|
6
5
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
): toolkit is BuiltinToolkitResponse {
|
|
10
|
-
return 'image_url' in toolkit
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export function toolById(
|
|
15
|
-
id: string,
|
|
16
|
-
toolkits: (BuiltinToolkitResponse | CustomToolkitDto)[] | undefined,
|
|
17
|
-
): ToolWithImage | undefined {
|
|
18
|
-
const tools = toolkits
|
|
19
|
-
?.map((toolkit) =>
|
|
20
|
-
toolkit.tools?.map((tool) => ({
|
|
21
|
-
...tool,
|
|
22
|
-
id: tool.id!,
|
|
23
|
-
image: isBuiltinToolkit(toolkit)
|
|
24
|
-
? toolkit.image_url ?? undefined
|
|
25
|
-
: (toolkit as CustomToolkitDto).avatar ?? undefined,
|
|
26
|
-
})),
|
|
27
|
-
)
|
|
28
|
-
.flat()
|
|
6
|
+
export function toolById(id: string, toolkits: BuiltinToolkitResponse[] | undefined): ToolWithImage | undefined {
|
|
7
|
+
const tools = toolkits?.map(({ image_url, tools }) => tools?.map((tool) => ({ ...tool, id: tool.id!, image: image_url! }))).flat()
|
|
29
8
|
return keyBy(tools, 'id')[id]
|
|
30
9
|
}
|
|
@@ -2,6 +2,7 @@ import { dataIntegrationClient } from '@stack-spot/portal-network'
|
|
|
2
2
|
import { FileUploadType } from '@stack-spot/portal-network/api/dataIntegration'
|
|
3
3
|
import { pull } from 'lodash'
|
|
4
4
|
import { FileUploadStatus } from './types'
|
|
5
|
+
import { getFileId } from './utils'
|
|
5
6
|
|
|
6
7
|
export type FileUploadChangeListener = (status: FileUploadStatus) => void
|
|
7
8
|
|
|
@@ -17,8 +18,8 @@ export class FileUpload {
|
|
|
17
18
|
|
|
18
19
|
constructor(file: File, type: FileUploadType = 'CONTEXT') {
|
|
19
20
|
this.file = file
|
|
21
|
+
this.id = getFileId(file)
|
|
20
22
|
this.type = type
|
|
21
|
-
this.id = `${Date.now()}-${Math.random()}`
|
|
22
23
|
this.upload()
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Text } from '@citric
|
|
2
|
-
import { Badge, Skeleton } from '@citric/ui'
|
|
1
|
+
import { Badge, Skeleton, Text } from '@stack-spot/citric-react'
|
|
3
2
|
import { agentToolsClient } from '@stack-spot/portal-network'
|
|
4
3
|
import { useMemo } from 'react'
|
|
5
4
|
import { ToolBadge } from '../../components/ToolBadge'
|
|
@@ -11,18 +10,18 @@ export const AgentDescription = ({ agentId }: { agentId?: string }) => {
|
|
|
11
10
|
const t = useAgentsDictionary()
|
|
12
11
|
const [agent, , , { isLoading }] = agentToolsClient.agent.useStatefulQuery({ agentId: agentId! }, { enabled: !!agentId })
|
|
13
12
|
const [toolKits, , , { isLoading: isLoadingToolKit }] = agentToolsClient.tools.useStatefulQuery({})
|
|
14
|
-
const numberOfKnowledgeSources = agent?.
|
|
13
|
+
const numberOfKnowledgeSources = agent?.knowledge_source_config?.knowledge_sources.length ?? 0
|
|
15
14
|
|
|
16
15
|
const knowledgeSources = useMemo(
|
|
17
|
-
() => agent?.
|
|
18
|
-
<li key={index}><Badge
|
|
16
|
+
() => agent?.knowledge_source_config?.knowledge_sources_details?.map((ks, index) => (
|
|
17
|
+
<li key={index}><Badge colorPalette="teal" appearance="square">{ks.name}</Badge></li>
|
|
19
18
|
)),
|
|
20
19
|
[agent],
|
|
21
20
|
)
|
|
22
21
|
const skeleton = useMemo(() => {
|
|
23
22
|
const loadingKS: React.ReactElement[] = []
|
|
24
23
|
for (let i = 0; i < numberOfKnowledgeSources; i++) {
|
|
25
|
-
loadingKS.push(<li key={i}><Badge
|
|
24
|
+
loadingKS.push(<li key={i}><Badge colorPalette="teal" appearance="square"><Skeleton className="ks-skeleton" /></Badge></li>)
|
|
26
25
|
}
|
|
27
26
|
return loadingKS
|
|
28
27
|
}, [numberOfKnowledgeSources])
|
|
@@ -70,7 +69,7 @@ export const AgentDescription = ({ agentId }: { agentId?: string }) => {
|
|
|
70
69
|
</section>}
|
|
71
70
|
{agent?.model_name && <section>
|
|
72
71
|
<Text appearance="microtext1" className="title">LLM</Text>
|
|
73
|
-
<Badge
|
|
72
|
+
<Badge colorPalette="orange" appearance="square">{agent?.model_name}</Badge>
|
|
74
73
|
</section>}
|
|
75
74
|
</AgentDescriptionBox>
|
|
76
75
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Tab } from '@stack-spot/citric-react'
|
|
1
2
|
import { agentToolsClient } from '@stack-spot/portal-network'
|
|
2
|
-
import {
|
|
3
|
+
import { useEffect, useRef } from 'react'
|
|
3
4
|
import { RightPanelContentList } from '../../components/RightPanelContentList'
|
|
4
5
|
import { RightPanelTabs } from '../../components/RightPanelTabs'
|
|
5
6
|
import { useCurrentChat, useWidgetState } from '../../context/hooks'
|
|
@@ -8,8 +9,6 @@ import { checkIsTrial } from '../../utils/check-is-trial'
|
|
|
8
9
|
import { AgentsTab, AgentsTabWorkspace } from './AgentsTab'
|
|
9
10
|
import { useAgentsDictionary } from './dictionary'
|
|
10
11
|
|
|
11
|
-
type TabElement = { title: string, content: ReactElement }
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* Renders the Agent selection form in the Right Panel if this is the panel that is currently opened.
|
|
15
14
|
*/
|
|
@@ -29,13 +28,13 @@ export const AgentsPanel = () => {
|
|
|
29
28
|
}
|
|
30
29
|
}, [chat])
|
|
31
30
|
|
|
32
|
-
const allTabsMap: Record<Scope,
|
|
33
|
-
favorite: {
|
|
34
|
-
builtin: {
|
|
35
|
-
personal: {
|
|
36
|
-
shared: {
|
|
37
|
-
workspace: {
|
|
38
|
-
account: {
|
|
31
|
+
const allTabsMap: Record<Scope, Omit<Tab, 'key'>> = {
|
|
32
|
+
favorite: { label: t.favorites, content: <AgentsTab key="favorite" visibility="favorite" agent={agent} /> },
|
|
33
|
+
builtin: { label: t.builtin, content: <AgentsTab key="builtin" visibility="built_in" agent={agent} /> },
|
|
34
|
+
personal: { label: t.personal, content: <AgentsTab key="personal" visibility="personal" agent={agent} /> },
|
|
35
|
+
shared: { label: t.shared, content: <AgentsTab key="shared" visibility="shared" agent={agent} /> },
|
|
36
|
+
workspace: { label: t.spots, content: <AgentsTabWorkspace key="workspace" visibility="workspace" agent={agent} /> },
|
|
37
|
+
account: { label: t.account, content: <AgentsTab key="account" visibility="account" agent={agent} /> },
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
const defaultScopes: Scope[] = ['favorite', 'builtin', 'personal', 'shared', 'workspace', 'account']
|
|
@@ -47,8 +46,8 @@ export const AgentsPanel = () => {
|
|
|
47
46
|
: rawScopes
|
|
48
47
|
|
|
49
48
|
const tabs = scopesToRender
|
|
50
|
-
.map(scope => allTabsMap[scope])
|
|
51
|
-
.filter(Boolean) as
|
|
49
|
+
.map(scope => scope in allTabsMap ? ({ key: scope, ...allTabsMap[scope] }) : undefined)
|
|
50
|
+
.filter(Boolean) as Tab[]
|
|
52
51
|
|
|
53
52
|
return (isGroupResourcesByScope ? (
|
|
54
53
|
<RightPanelTabs key={chat.id} tabs={tabs} />
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { Button } from '@stack-spot/citric-react'
|
|
3
3
|
import { Placeholder } from '@stack-spot/portal-components/Placeholder'
|
|
4
|
-
import { MiniLogo } from '@stack-spot/portal-components/svg'
|
|
5
4
|
import { AgentResponseWithBuiltIn, agentToolsClient, AgentVisibilityLevel, workspaceAiClient } from '@stack-spot/portal-network'
|
|
6
5
|
import { WorkspaceResponse } from '@stack-spot/portal-network/api/workspace-ai'
|
|
7
|
-
import {
|
|
8
|
-
import { ButtonFavorite } from '../../components/ButtonFavorite'
|
|
6
|
+
import { useMemo, useState } from 'react'
|
|
9
7
|
import { NavigationComponent } from '../../components/ComponentNavigator'
|
|
10
8
|
import { DescribedRadioGroup } from '../../components/form/DescribedRadioGroup'
|
|
11
|
-
import { IconInput } from '../../components/IconInput'
|
|
12
9
|
import { WorkspaceTabNavigator } from '../../components/WorkspaceTabNavigator'
|
|
13
10
|
import { useCurrentChat } from '../../context/hooks'
|
|
14
11
|
import { useRightPanel } from '../../right-panel/hooks'
|
|
15
12
|
import { ChatProperties } from '../../state/ChatState'
|
|
16
13
|
import { AgentDescription } from './AgentDescription'
|
|
17
14
|
import { useAgentsDictionary } from './dictionary'
|
|
18
|
-
import { AgentLabel } from './styled'
|
|
19
15
|
import { useAgentFavorites } from './useAgentFavorites'
|
|
20
16
|
|
|
21
17
|
export interface AgentTabProps {
|
|
@@ -29,73 +25,58 @@ export const AgentsTab = ({ visibility, workspaceId, agent, showSubmitButton = t
|
|
|
29
25
|
const t = useAgentsDictionary()
|
|
30
26
|
const { close } = useRightPanel()
|
|
31
27
|
const chat = useCurrentChat()
|
|
32
|
-
const [filter, setFilter] = useState('')
|
|
33
28
|
const { useFavorites, onAddFavorite, onRemoveFavorite } = useAgentFavorites()
|
|
29
|
+
const [submitEnabled, setSubmitEnabled] = useState(false)
|
|
34
30
|
const listFavorites = useFavorites()
|
|
35
31
|
const agentDefault = agentToolsClient.agentDefault.useQuery()
|
|
36
32
|
const agents = workspaceId
|
|
37
33
|
? workspaceAiClient.getAgentFromWorkspaceAi.useQuery({ workspaceId }) as AgentResponseWithBuiltIn[]
|
|
38
34
|
: agentToolsClient.agents.useQuery({ visibility })
|
|
39
35
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
[agents, filter, value, listFavorites],
|
|
36
|
+
const initialValue = useMemo<AgentResponseWithBuiltIn | undefined>(
|
|
37
|
+
() => {
|
|
38
|
+
const initial = agent.current
|
|
39
|
+
? agents.find(a => a.id === agent.current?.id)
|
|
40
|
+
: chat.get('agent') ? agents.find(a => a.id === chat.get('agent')?.id) : agentDefault as unknown as AgentResponseWithBuiltIn
|
|
41
|
+
if (initial) setSubmitEnabled(true)
|
|
42
|
+
return initial
|
|
43
|
+
},
|
|
44
|
+
[agents],
|
|
50
45
|
)
|
|
51
46
|
|
|
52
47
|
function submit() {
|
|
53
|
-
if (
|
|
54
|
-
chat.set(
|
|
55
|
-
'agent',
|
|
56
|
-
{ id: value.id, label: value.name, image: value.avatar!, builtIn: value.visibility_level === 'built_in', slug: value.slug },
|
|
57
|
-
)
|
|
58
|
-
}
|
|
48
|
+
if (agent.current) chat.set('agent', agent.current)
|
|
59
49
|
close()
|
|
60
50
|
}
|
|
61
51
|
|
|
62
|
-
const onChange = useCallback((newValue: AgentResponseWithBuiltIn) => {
|
|
63
|
-
setValue(newValue)
|
|
64
|
-
agent.current = { ...newValue, label: newValue.name, builtIn: newValue.visibility_level === 'built_in' }
|
|
65
|
-
}, [])
|
|
66
|
-
|
|
67
52
|
return (
|
|
68
53
|
<>
|
|
69
54
|
<div className="content">
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
: ''
|
|
55
|
+
<DescribedRadioGroup
|
|
56
|
+
options={agents}
|
|
57
|
+
initialValue={initialValue}
|
|
58
|
+
onChange={(ag) => {
|
|
59
|
+
agent.current = ag
|
|
60
|
+
? { ...ag, label: ag.name, image: ag.avatar!, slug: ag.slug, builtIn: ag.visibility_level === 'built_in' }
|
|
61
|
+
: undefined
|
|
62
|
+
setSubmitEnabled(true)
|
|
63
|
+
}}
|
|
64
|
+
data={ag => ({
|
|
65
|
+
idOrSlug: ag.id,
|
|
66
|
+
image: ag.avatar ? <img src={ag.avatar} /> : <Icon icon="Agent" />,
|
|
67
|
+
description: <AgentDescription agentId={ag.id} />,
|
|
68
|
+
name: ag.name,
|
|
69
|
+
listFavorites,
|
|
70
|
+
onAddFavorite,
|
|
71
|
+
onRemoveFavorite,
|
|
72
|
+
})}
|
|
73
|
+
emptyResults={
|
|
74
|
+
<Placeholder title={t.noSearchResults} description={t.noSearchResultsDescription} className="no-data-placeholder" />
|
|
91
75
|
}
|
|
92
|
-
|
|
93
|
-
/>
|
|
94
|
-
{!!agents.length && !filtered.length &&
|
|
95
|
-
<Placeholder title={t.noSearchResults} description={t.noSearchResultsDescription} className="no-data-placeholder" />}
|
|
96
|
-
{!agents.length && <Placeholder title={t.noData} description={t.noDataDescription} />}
|
|
76
|
+
emptyDataset={<Placeholder title={t.noData} description={t.noDataDescription} />}
|
|
77
|
+
/>
|
|
97
78
|
</div>
|
|
98
|
-
{!!
|
|
79
|
+
{!!agents.length && showSubmitButton && <Button onClick={submit} disabled={!submitEnabled}>{t.apply}</Button>}
|
|
99
80
|
</>
|
|
100
81
|
)
|
|
101
82
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { ImageWithFallback, Text } from '@stack-spot/citric-react'
|
|
3
3
|
import { LabeledWithImage } from '../../state/types'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -12,10 +12,11 @@ interface Props {
|
|
|
12
12
|
*/
|
|
13
13
|
export const AgentInfo = ({ agent, icon }: Props) => (
|
|
14
14
|
<>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
<ImageWithFallback
|
|
16
|
+
src={agent?.image ?? ''}
|
|
17
|
+
className="custom-agent-image"
|
|
18
|
+
fallback={<div className="default-image-wrapper">{icon ?? <Icon icon="Agent" className="agent-image" />}</div>}
|
|
19
|
+
/>
|
|
19
20
|
<Text appearance="body2">{agent?.label}</Text>
|
|
20
21
|
</>
|
|
21
22
|
)
|