@stack-spot/ai-chat-widget 3.6.2-beta.5 → 3.7.0-beta.5
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 +23 -45
- package/dist/app-metadata.json +3 -3
- package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
- package/dist/chat-interceptors/quick-commands.js +14 -5
- package/dist/chat-interceptors/quick-commands.js.map +1 -1
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +6 -2
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/Selector/SelectVersion.d.ts +12 -0
- package/dist/components/Selector/SelectVersion.d.ts.map +1 -0
- package/dist/components/Selector/SelectVersion.js +33 -0
- package/dist/components/Selector/SelectVersion.js.map +1 -0
- package/dist/components/Selector/index.d.ts +13 -2
- package/dist/components/Selector/index.d.ts.map +1 -1
- package/dist/components/Selector/index.js +23 -19
- package/dist/components/Selector/index.js.map +1 -1
- package/dist/components/Selector/styled.d.ts +2 -0
- package/dist/components/Selector/styled.d.ts.map +1 -1
- package/dist/components/Selector/styled.js +46 -0
- package/dist/components/Selector/styled.js.map +1 -1
- package/dist/hooks/enabled-feature-flags.d.ts +5 -0
- package/dist/hooks/enabled-feature-flags.d.ts.map +1 -0
- package/dist/hooks/enabled-feature-flags.js +28 -0
- package/dist/hooks/enabled-feature-flags.js.map +1 -0
- package/dist/state/types.d.ts +1 -0
- package/dist/state/types.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tools.d.ts +5 -5
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +2 -2
- package/dist/utils/tools.js.map +1 -1
- package/dist/views/Agents/AgentDescription.d.ts +2 -1
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
- package/dist/views/Agents/AgentDescription.js +21 -10
- package/dist/views/Agents/AgentDescription.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +6 -3
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/Agents/dictionary.d.ts.map +1 -1
- package/dist/views/Agents/dictionary.js +2 -0
- package/dist/views/Agents/dictionary.js.map +1 -1
- package/dist/views/Chat/ButtonExecutionDetail.js +6 -6
- package/dist/views/Chat/ButtonExecutionDetail.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +1 -2
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/ChatHistory/utils.js +1 -1
- package/dist/views/ChatHistory/utils.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +19 -7
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/ModelSwitcher/utils.d.ts +2 -2
- package/dist/views/MessageInput/ModelSwitcher/utils.d.ts.map +1 -1
- package/dist/views/MessageInput/ModelSwitcher/utils.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +12 -8
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
- package/dist/views/Steps/FlowChart/{NodeTool.d.ts → NodeDynamic.d.ts} +2 -2
- package/dist/views/Steps/FlowChart/NodeDynamic.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/{NodeTool.js → NodeDynamic.js} +5 -5
- package/dist/views/Steps/FlowChart/NodeDynamic.js.map +1 -0
- package/dist/views/Steps/FlowChart/NodeStep.js +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -1
- package/dist/views/Steps/FlowChart/hooks.d.ts +1 -1
- package/dist/views/Steps/FlowChart/hooks.d.ts.map +1 -1
- package/dist/views/Steps/FlowChart/hooks.js +4 -2
- package/dist/views/Steps/FlowChart/hooks.js.map +1 -1
- package/dist/views/Steps/FlowChart/index.js +3 -3
- package/dist/views/Steps/FlowChart/index.js.map +1 -1
- package/dist/views/Steps/utils.d.ts.map +1 -1
- package/dist/views/Steps/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/app-metadata.json +3 -3
- package/src/chat-interceptors/quick-commands.ts +14 -5
- package/src/chat-interceptors/send-message.ts +6 -2
- package/src/components/Selector/SelectVersion.tsx +55 -0
- package/src/components/Selector/index.tsx +57 -35
- package/src/components/Selector/styled.ts +48 -0
- package/src/hooks/enabled-feature-flags.ts +31 -0
- package/src/state/types.ts +1 -0
- package/src/types.ts +0 -1
- package/src/utils/tools.ts +4 -4
- package/src/views/Agents/AgentDescription.tsx +36 -14
- package/src/views/Agents/AgentsTab.tsx +13 -11
- package/src/views/Agents/dictionary.ts +2 -1
- package/src/views/Chat/ButtonExecutionDetail.tsx +6 -6
- package/src/views/Chat/ChatMessage.tsx +1 -2
- package/src/views/ChatHistory/utils.ts +4 -4
- package/src/views/MessageInput/AgentSelector.tsx +24 -12
- package/src/views/MessageInput/ModelSwitcher/utils.tsx +2 -2
- package/src/views/MessageInput/QuickCommandSelector.tsx +33 -23
- package/src/views/Steps/FlowChart/{NodeTool.tsx → NodeDynamic.tsx} +6 -6
- package/src/views/Steps/FlowChart/NodeStep.tsx +1 -1
- package/src/views/Steps/FlowChart/hooks.ts +3 -2
- package/src/views/Steps/FlowChart/index.tsx +3 -3
- package/src/views/Steps/utils.tsx +1 -1
- package/dist/views/Steps/FlowChart/NodeTool.d.ts.map +0 -1
- package/dist/views/Steps/FlowChart/NodeTool.js.map +0 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Icon } from '@stack-spot/citric-icons'
|
|
2
2
|
import { IconBox, Row, Text } from '@stack-spot/citric-react'
|
|
3
|
-
import { AgentResponseWithBuiltIn, agentToolsClient, workspaceAiClient } from '@stack-spot/portal-network'
|
|
3
|
+
import { AgentResponseWithBuiltIn, agentToolsClient, AgentVisibilityLevel, workspaceAiClient } from '@stack-spot/portal-network'
|
|
4
|
+
import { VisibilityLevelEnum } from '@stack-spot/portal-network/api/agent-tools'
|
|
4
5
|
import { useCallback } from 'react'
|
|
5
6
|
import { Selector } from '../../components/Selector'
|
|
6
7
|
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks'
|
|
8
|
+
import { useIsFeatureFlagEnabled } from '../../hooks/enabled-feature-flags'
|
|
7
9
|
import { agentRegex } from '../../regex'
|
|
8
10
|
import { useAgentFavorites } from '../Agents/useAgentFavorites'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const AgentItem = ({ avatar, name, spaceName }: AgentWithSpaceName) => {
|
|
12
|
+
const AgentItem = ({ avatar, name, spaceName }: AgentResponseWithBuiltIn) => {
|
|
13
13
|
const avatarComponent = avatar
|
|
14
14
|
? <img style={{ width: '32px', height: '32px', borderRadius: '50%' }} src={avatar} />
|
|
15
15
|
: <IconBox size="md" icon="Agent" style={{ backgroundColor: 'transparent' }} />
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
return <Row gap="8px" style={{ flexWrap: 'nowrap' }}>
|
|
18
19
|
{avatarComponent}
|
|
19
20
|
<div>
|
|
@@ -30,10 +31,11 @@ export const AgentSelector = ({ inputRef, isTrial }: {
|
|
|
30
31
|
const chat = useCurrentChat()
|
|
31
32
|
const isAgentEnabled = useCurrentChatState('features').agent
|
|
32
33
|
const spotId = useWidgetState('features')?.workspaceId
|
|
34
|
+
const featureFlag = useIsFeatureFlagEnabled('ENABLE_VERSION_CONTENT_AI')
|
|
33
35
|
|
|
34
36
|
const { useFavorites, onAddFavorite, onRemoveFavorite } = useAgentFavorites()
|
|
35
37
|
|
|
36
|
-
const onSelectItem = useCallback(async (agent: AgentResponseWithBuiltIn) => {
|
|
38
|
+
const onSelectItem = useCallback(async (agent: AgentResponseWithBuiltIn, selectedVersion?: number) => {
|
|
37
39
|
const newValue = `@${agent.slug}`
|
|
38
40
|
chat.set('nextMessage', undefined)
|
|
39
41
|
chat.set(
|
|
@@ -41,10 +43,11 @@ export const AgentSelector = ({ inputRef, isTrial }: {
|
|
|
41
43
|
{
|
|
42
44
|
id: agent.id,
|
|
43
45
|
label: agent.name,
|
|
44
|
-
image: agent.avatar,
|
|
46
|
+
image: agent.avatar,
|
|
45
47
|
slug: agent.slug,
|
|
46
48
|
builtIn: agent.builtIn,
|
|
47
49
|
visibility_level: agent.visibility_level,
|
|
50
|
+
agent_version_number: selectedVersion || agent.version_number,
|
|
48
51
|
},
|
|
49
52
|
)
|
|
50
53
|
|
|
@@ -54,18 +57,25 @@ export const AgentSelector = ({ inputRef, isTrial }: {
|
|
|
54
57
|
}, [chat, inputRef])
|
|
55
58
|
|
|
56
59
|
|
|
57
|
-
const getAgents = () => {
|
|
60
|
+
const getAgents = ({ filter, visibility }: {filter?: string, visibility?: AgentVisibilityLevel[] | VisibilityLevelEnum[]}) => {
|
|
58
61
|
if (spotId) {
|
|
59
|
-
return workspaceAiClient.getAgentFromWorkspaceAi.useQuery({
|
|
62
|
+
return { data: workspaceAiClient.getAgentFromWorkspaceAi.useQuery({
|
|
63
|
+
workspaceId: spotId, name: filter }) as AgentResponseWithBuiltIn[] }
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
if (isTrial) {
|
|
63
|
-
return agentToolsClient.allAgents.useQuery({ visibilities: [
|
|
67
|
+
return { data: agentToolsClient.allAgents.useQuery({ visibilities: visibility as VisibilityLevelEnum[], filter }) }
|
|
64
68
|
}
|
|
69
|
+
|
|
70
|
+
return { data: agentToolsClient.allAgents.useQuery({
|
|
71
|
+
visibilities: visibility as VisibilityLevelEnum[], filter,
|
|
72
|
+
}) }
|
|
73
|
+
}
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
const getAgentVersions = (id: string, enabled: boolean) => {
|
|
76
|
+
const [listVersions] = agentToolsClient.listAgentVersions.useStatefulQuery({ agentCoreId: id }, { enabled })
|
|
77
|
+
const optionsVersions = listVersions?.map((version) => version.version_number)
|
|
78
|
+
return optionsVersions
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
return <Selector
|
|
@@ -83,8 +93,10 @@ export const AgentSelector = ({ inputRef, isTrial }: {
|
|
|
83
93
|
['favorite', 'personal', 'workspace', 'account', 'shared', 'built_in', 'recently_used'],
|
|
84
94
|
renderComponentItem: AgentItem,
|
|
85
95
|
isEnabled: isAgentEnabled,
|
|
96
|
+
isEnabledVersionContent: featureFlag.flagEnabled,
|
|
86
97
|
onSelect: onSelectItem,
|
|
87
98
|
useData: getAgents,
|
|
99
|
+
useVersions: getAgentVersions,
|
|
88
100
|
}}
|
|
89
101
|
/>
|
|
90
102
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CitricIconOutline, CitricIconSocial } from '@stack-spot/citric-icons'
|
|
2
2
|
import { IconBox } from '@stack-spot/citric-react'
|
|
3
|
-
import {
|
|
3
|
+
import { FindByIdAgentResponse } from '@stack-spot/portal-network/api/agent-tools'
|
|
4
4
|
import { LlmModelsResponse, PaginatedResponseLlmModelsResponse } from '@stack-spot/portal-network/api/genAiInference'
|
|
5
5
|
import { theme } from '@stack-spot/portal-theme'
|
|
6
6
|
import { Dispatch, ReactElement } from 'react'
|
|
@@ -27,7 +27,7 @@ export const providerIcon: Record<string, CitricIconSocial | CitricIconOutline>
|
|
|
27
27
|
export function getListModelsData(
|
|
28
28
|
chat: ChatState,
|
|
29
29
|
setVisibleMenu: Dispatch<React.SetStateAction<boolean>>,
|
|
30
|
-
agent?:
|
|
30
|
+
agent?: FindByIdAgentResponse,
|
|
31
31
|
models?: PaginatedResponseLlmModelsResponse) {
|
|
32
32
|
|
|
33
33
|
const chatSelectedModelId = chat.get('selected_model_id')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
-
import { aiClient, workspaceAiClient } from '@stack-spot/portal-network'
|
|
3
|
-
import { QuickCommandResponse } from '@stack-spot/portal-network/api/ai'
|
|
2
|
+
import { AgentVisibilityLevel, aiClient, workspaceAiClient } from '@stack-spot/portal-network'
|
|
3
|
+
import { QuickCommandResponse, VisibilityLevelEnum } from '@stack-spot/portal-network/api/ai'
|
|
4
4
|
import { useCallback } from 'react'
|
|
5
5
|
import { Selector } from '../../components/Selector'
|
|
6
6
|
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks'
|
|
@@ -8,17 +8,16 @@ import { quickCommandRegex } from '../../regex'
|
|
|
8
8
|
|
|
9
9
|
type QuickCommandResponseWithSpaceName = QuickCommandResponse & { spaceName?: string }
|
|
10
10
|
|
|
11
|
-
export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
11
|
+
export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
12
12
|
{ isTrial: boolean, inputRef: React.RefObject<HTMLTextAreaElement | HTMLInputElement> }) => {
|
|
13
13
|
const chat = useCurrentChat()
|
|
14
|
-
const isQuickCommandEnabled =
|
|
14
|
+
const isQuickCommandEnabled = useCurrentChatState('features').quickCommands
|
|
15
15
|
const spotId = useWidgetState('features')?.workspaceId
|
|
16
16
|
|
|
17
|
-
const useFavorites = () => aiClient.allQuickCommands.useQuery({ visibility: 'favorite' })
|
|
18
17
|
const [addFavorite, pendingAddFav] = aiClient.addFavoriteQuickCommand.useMutation()
|
|
19
18
|
const [removeFavorite, pendingRemoveFav] = aiClient.removeFavoriteQuickCommand.useMutation()
|
|
20
19
|
|
|
21
|
-
const addFavoriteQc = async(idOrSlug?: string) => {
|
|
20
|
+
const addFavoriteQc = async (idOrSlug?: string) => {
|
|
22
21
|
try {
|
|
23
22
|
await addFavorite({ slug: idOrSlug || '' })
|
|
24
23
|
await aiClient.allQuickCommands.invalidate()
|
|
@@ -32,7 +31,7 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
32
31
|
const onAddFavorite = (idOrSlug?: string) => new Promise<boolean>(async (resolve, reject) => {
|
|
33
32
|
try {
|
|
34
33
|
await addFavoriteQc(idOrSlug)
|
|
35
|
-
if (!pendingAddFav){
|
|
34
|
+
if (!pendingAddFav) {
|
|
36
35
|
resolve(true)
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -40,10 +39,10 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
40
39
|
// eslint-disable-next-line no-console
|
|
41
40
|
console.error(error)
|
|
42
41
|
reject(error)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
42
|
+
}
|
|
43
|
+
})
|
|
45
44
|
|
|
46
|
-
const removeFavoriteQc = async(idOrSlug?: string) => {
|
|
45
|
+
const removeFavoriteQc = async (idOrSlug?: string) => {
|
|
47
46
|
try {
|
|
48
47
|
await removeFavorite({ slug: idOrSlug || '' })
|
|
49
48
|
await aiClient.allQuickCommands.invalidate()
|
|
@@ -57,7 +56,7 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
57
56
|
const onRemoveFavorite = (idOrSlug?: string) => new Promise<boolean>(async (resolve, reject) => {
|
|
58
57
|
try {
|
|
59
58
|
await removeFavoriteQc(idOrSlug)
|
|
60
|
-
if (!pendingRemoveFav){
|
|
59
|
+
if (!pendingRemoveFav) {
|
|
61
60
|
resolve(true)
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -65,9 +64,9 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
65
64
|
// eslint-disable-next-line no-console
|
|
66
65
|
console.error(error)
|
|
67
66
|
reject(error)
|
|
68
|
-
}
|
|
67
|
+
}
|
|
69
68
|
})
|
|
70
|
-
|
|
69
|
+
|
|
71
70
|
const onSelectItem = useCallback((qc: QuickCommandResponseWithSpaceName) => {
|
|
72
71
|
const newValue = `/${qc.slug}`
|
|
73
72
|
chat.set('nextMessage', newValue)
|
|
@@ -77,12 +76,19 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
77
76
|
inputRef.current.focus()
|
|
78
77
|
}, [chat, inputRef])
|
|
79
78
|
|
|
80
|
-
const getQuickCommands = () => {
|
|
79
|
+
const getQuickCommands = ({ filter, visibility }: { filter?: string, visibility?: AgentVisibilityLevel[] | VisibilityLevelEnum[] }) => {
|
|
80
|
+
|
|
81
81
|
if (spotId) {
|
|
82
|
-
return workspaceAiClient.getQCFromWorkspaceAi.useQuery({ workspaceId: spotId })
|
|
82
|
+
return { data: workspaceAiClient.getQCFromWorkspaceAi.useQuery({ workspaceId: spotId, name: filter }) }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const quickCommands = aiClient.
|
|
85
|
+
const [quickCommands, { fetchNextPage, hasNextPage }] = aiClient.allQuickCommandsV3.useInfiniteQuery({
|
|
86
|
+
order: 'a-to-z',
|
|
87
|
+
visibilityList: visibility as VisibilityLevelEnum[],
|
|
88
|
+
name: filter,
|
|
89
|
+
page: 1, size: 20,
|
|
90
|
+
})
|
|
91
|
+
|
|
86
92
|
const quickCommandsFiltered = quickCommands.filter(
|
|
87
93
|
(qc) => qc.visibility_level.toLowerCase() !== 'workspace',
|
|
88
94
|
)
|
|
@@ -92,11 +98,17 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
92
98
|
})
|
|
93
99
|
|
|
94
100
|
const workspaceQuickCommandsWithWorkspaceName: QuickCommandResponseWithSpaceName[] =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
workspaceQuickCommands.flatMap(({ qcs, space_name }) =>
|
|
102
|
+
qcs?.map((qc) => ({ ...qc, spaceName: space_name })),
|
|
103
|
+
) as QuickCommandResponseWithSpaceName[]
|
|
104
|
+
|
|
105
|
+
const filteredWorkspaceQuickCommand = filter ? workspaceQuickCommandsWithWorkspaceName?.filter((qc) =>
|
|
106
|
+
qc.name?.toLowerCase().includes(filter!)) : workspaceQuickCommandsWithWorkspaceName
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
const data = !visibility ? [...quickCommandsFiltered, ...filteredWorkspaceQuickCommand] : (
|
|
109
|
+
visibility.includes('workspace') ? filteredWorkspaceQuickCommand : quickCommandsFiltered
|
|
110
|
+
)
|
|
111
|
+
return { data, fetchNextPage: fetchNextPage, hasNextPage }
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
const QuickCommandItem = ({ slug, description, spaceName }: QuickCommandResponseWithSpaceName) => <>
|
|
@@ -107,9 +119,7 @@ export const QuickCommandSelector = ({ inputRef, isTrial }:
|
|
|
107
119
|
|
|
108
120
|
return <Selector
|
|
109
121
|
inputRef={inputRef}
|
|
110
|
-
favorite={{
|
|
111
|
-
useFavorites, onAddFavorite, onRemoveFavorite, favoriteIsSlug: true,
|
|
112
|
-
}}
|
|
122
|
+
favorite={{ onAddFavorite, onRemoveFavorite, favoriteIsSlug: true }}
|
|
113
123
|
selectorConfig={{
|
|
114
124
|
resourceName: 'Quick Command',
|
|
115
125
|
shortcut: '/',
|
|
@@ -44,10 +44,10 @@ export const ListTools = ({ tools, onClick }: { tools: ChatAgentTool[], onClick?
|
|
|
44
44
|
</AnimatedHeight>
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
const
|
|
47
|
+
const NodeBox = ({ title, icon, content, onClick }: { title: string, icon: WithIcon, content?: string, onClick?: () => void }) => (
|
|
48
48
|
<Column onClick={onClick} style={{ cursor: onClick ? 'pointer' : 'default' }}>
|
|
49
|
-
<Row>
|
|
50
|
-
<IconBox {...icon} appearance="
|
|
49
|
+
<Row gap="4px" alignItems="center">
|
|
50
|
+
<IconBox {...icon} appearance="none" colorScheme="light" size="sm" />
|
|
51
51
|
<Text className="step-index" weight="500">{title}</Text>
|
|
52
52
|
</Row>
|
|
53
53
|
<Text nowrapEllipsis color="light.700">
|
|
@@ -62,7 +62,7 @@ interface Props {
|
|
|
62
62
|
sourcePosition?: Position,
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export const
|
|
65
|
+
export const NodeDynamic = ({ data, ...props }: Props) => {
|
|
66
66
|
const { step, index, onClick, onResize, message } = data
|
|
67
67
|
const content = useChatEntry(message)?.content
|
|
68
68
|
const t = useStepsDictionary()
|
|
@@ -72,7 +72,7 @@ export const NodeTool = ({ data, ...props }: Props) => {
|
|
|
72
72
|
|
|
73
73
|
const renderContent = () => {
|
|
74
74
|
if (step.type === 'planning') {
|
|
75
|
-
return <
|
|
75
|
+
return <NodeBox title={t.userPrompt} content={step.user_question} icon={{ ...getTypeIcon(step.type) }} />
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
if (step.type === 'step') {
|
|
@@ -81,7 +81,7 @@ export const NodeTool = ({ data, ...props }: Props) => {
|
|
|
81
81
|
|
|
82
82
|
if (step.type === 'answer') {
|
|
83
83
|
return <Column p={3} bg="light.400" onClick={() => onClick?.(index)}>
|
|
84
|
-
<
|
|
84
|
+
<NodeBox onClick={onClick} title={t.finalAnswer} content={content} icon={{ ...getTypeIcon(step.type) }} />
|
|
85
85
|
</Column>
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -32,7 +32,7 @@ export const NodeStep = ({ data: { step, index, nextStatus, onClick }, ...props
|
|
|
32
32
|
{getStatusIcon(step.status)}
|
|
33
33
|
</header>
|
|
34
34
|
{step.type === 'planning' && <Text className="step-title">{step.goal}</Text>}
|
|
35
|
-
{step.type === 'step' && step.input && <Text className="step-title">
|
|
35
|
+
{step.type === 'step' && step.input && <Text className="step-title">{step.input}</Text>}
|
|
36
36
|
{step.type === 'step' && <div className="step-details">
|
|
37
37
|
<Text className={listToClass(['step-description', !!step.attempts[0].tools?.length && 'with-tools'])}>
|
|
38
38
|
{step.output}
|
|
@@ -6,7 +6,7 @@ interface Size {
|
|
|
6
6
|
height: number,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const useResizeObserver = (callback?: (size: Size) => void) => {
|
|
9
|
+
export const useResizeObserver = (callback?: (size: Size) => void, delay = 50) => {
|
|
10
10
|
const ref = useRef<HTMLDivElement | null>(null)
|
|
11
11
|
const previousSizeRef = useRef<Size | null>(null)
|
|
12
12
|
|
|
@@ -21,9 +21,10 @@ export const useResizeObserver = (callback?: (size: Size) => void) => {
|
|
|
21
21
|
previousSizeRef.current = newSize
|
|
22
22
|
callback(newSize)
|
|
23
23
|
}
|
|
24
|
-
},
|
|
24
|
+
}, delay)
|
|
25
25
|
|
|
26
26
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
27
|
+
if (!entries.length) return
|
|
27
28
|
const { width, height } = entries[0].contentRect
|
|
28
29
|
debouncedCallback({ width, height })
|
|
29
30
|
})
|
|
@@ -7,8 +7,8 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
|
7
7
|
import { useChatEntry } from '../../../context/hooks'
|
|
8
8
|
import { ChatEntry } from '../../../state/ChatEntry'
|
|
9
9
|
import { LayoutDirection, useLayoutedElements } from './layout'
|
|
10
|
+
import { NodeDynamic } from './NodeDynamic'
|
|
10
11
|
import { NodeStep } from './NodeStep'
|
|
11
|
-
import { NodeTool } from './NodeTool'
|
|
12
12
|
import { FlowChartBox } from './styled'
|
|
13
13
|
import { NodeFullProps } from './types'
|
|
14
14
|
|
|
@@ -20,7 +20,7 @@ interface Props {
|
|
|
20
20
|
|
|
21
21
|
const NODE_TYPES = {
|
|
22
22
|
step: { planning: NodeStep, step: NodeStep, answer: NodeStep },
|
|
23
|
-
|
|
23
|
+
stepDynamic: { planning: NodeDynamic, step: NodeDynamic, answer: NodeDynamic },
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const Flow = ({ message, onClick, direction = 'LR' }: Props) => {
|
|
@@ -29,7 +29,7 @@ const Flow = ({ message, onClick, direction = 'LR' }: Props) => {
|
|
|
29
29
|
const reactFlowInstance = useReactFlow()
|
|
30
30
|
|
|
31
31
|
const isDynamic = useMemo(() => steps?.some((step) => step.id === 'dynamic'), [steps])
|
|
32
|
-
const nodeTypes = useMemo(() => NODE_TYPES[isDynamic ? '
|
|
32
|
+
const nodeTypes = useMemo(() => NODE_TYPES[isDynamic ? 'stepDynamic' : 'step'], [isDynamic])
|
|
33
33
|
|
|
34
34
|
const handleNodeSizeChange = useCallback((id: string, size: { width: number, height: number }) => {
|
|
35
35
|
setNodeSizes((prev) => {
|
|
@@ -12,7 +12,7 @@ export function getStatusIcon(status: ChatStep['status']) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function
|
|
15
|
+
export function getTypeIcon(type: ChatStep['type']): WithIcon {
|
|
16
16
|
switch (type) {
|
|
17
17
|
case 'planning': return { group: 'fill', icon: 'ChevronRight' }
|
|
18
18
|
default: return { group: 'outline', icon: 'StackSpot' }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTool.d.ts","sourceRoot":"","sources":["../../../../src/views/Steps/FlowChart/NodeTool.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAMxC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAuBlC,eAAO,MAAM,SAAS,uBAAwB;IAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,4CAU/G,CAAA;AAcD,UAAU,KAAK;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAED,eAAO,MAAM,QAAQ,uBAAwB,KAAK,4CAgCjD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTool.js","sourceRoot":"","sources":["../../../../src/views/Steps/FlowChart/NodeTool.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACvF,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