@stack-spot/ai-chat-widget 3.3.1-beta.5 → 3.3.3-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 +18 -14
- package/dist/app-metadata.json +3 -3
- package/dist/chat-interceptors/send-message.d.ts +1 -1
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +25 -29
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/form/DescribedRadioGroup.d.ts +3 -1
- 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/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +11 -8
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/useAgentFavorites.d.ts +1 -1
- package/dist/views/Agents/useAgentFavorites.js +3 -3
- package/dist/views/Agents/useAgentFavorites.js.map +1 -1
- package/dist/views/Chat/ChatMessage.js +1 -1
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts +2 -1
- package/dist/views/Chat/StepsList.d.ts.map +1 -1
- package/dist/views/Chat/StepsList.js +7 -6
- package/dist/views/Chat/StepsList.js.map +1 -1
- package/dist/views/MessageInput/ModelSwitcher/index.d.ts.map +1 -1
- package/dist/views/MessageInput/ModelSwitcher/index.js +1 -1
- package/dist/views/MessageInput/ModelSwitcher/index.js.map +1 -1
- package/package.json +2 -2
- package/src/app-metadata.json +3 -3
- package/src/chat-interceptors/send-message.ts +25 -30
- package/src/components/form/DescribedRadioGroup.tsx +84 -40
- package/src/views/Agents/AgentsTab.tsx +42 -35
- package/src/views/Agents/useAgentFavorites.ts +3 -3
- package/src/views/Chat/ChatMessage.tsx +1 -1
- package/src/views/Chat/StepsList.tsx +7 -6
- package/src/views/MessageInput/ModelSwitcher/index.tsx +2 -1
|
@@ -29,16 +29,22 @@ export const AgentsTab = ({ visibility, workspaceId, agent, showSubmitButton = t
|
|
|
29
29
|
const [submitEnabled, setSubmitEnabled] = useState(false)
|
|
30
30
|
const listFavorites = useFavorites()
|
|
31
31
|
const agentDefault = agentToolsClient.agentDefault.useQuery()
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const data = workspaceAiClient.getAgentFromWorkspaceAi.useStatefulQuery({ workspaceId: workspaceId! },
|
|
33
|
+
{ enabled: !!workspaceId })
|
|
34
|
+
const workspaceAgents = data?.[0] as AgentResponseWithBuiltIn[]
|
|
35
|
+
const [agentsData=[], { hasNextPage, fetchNextPage }] =
|
|
36
|
+
agentToolsClient.agentsMultipleFilters.useInfiniteQuery({
|
|
37
|
+
filters: { visibility_list: [visibility!], page: 1, size: 20 },
|
|
38
|
+
}, { enabled: !workspaceId && !!visibility })
|
|
39
|
+
|
|
40
|
+
const agents = workspaceId ? workspaceAgents : agentsData
|
|
35
41
|
|
|
36
42
|
const initialValue = useMemo<AgentResponseWithBuiltIn | undefined>(
|
|
37
43
|
() => {
|
|
38
44
|
const initial = agent.current
|
|
39
|
-
? agents
|
|
40
|
-
: chat.get('agent') ? agents
|
|
41
|
-
if (initial) setSubmitEnabled(true)
|
|
45
|
+
? agents?.find(a => a.id === agent.current?.id)
|
|
46
|
+
: chat.get('agent') ? agents?.find(a => a.id === chat.get('agent')?.id) : agentDefault as unknown as AgentResponseWithBuiltIn
|
|
47
|
+
if (initial && !submitEnabled) setSubmitEnabled(true)
|
|
42
48
|
return initial
|
|
43
49
|
},
|
|
44
50
|
[agents],
|
|
@@ -49,35 +55,36 @@ export const AgentsTab = ({ visibility, workspaceId, agent, showSubmitButton = t
|
|
|
49
55
|
close()
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
return (
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
58
|
+
return (<>
|
|
59
|
+
<div className="content">
|
|
60
|
+
<DescribedRadioGroup
|
|
61
|
+
fetchNextPage={fetchNextPage}
|
|
62
|
+
hasNextPage={hasNextPage}
|
|
63
|
+
options={agents}
|
|
64
|
+
initialValue={initialValue}
|
|
65
|
+
onChange={(ag) => {
|
|
66
|
+
agent.current = ag
|
|
67
|
+
? { ...ag, label: ag.name, image: ag.avatar!, slug: ag.slug, builtIn: ag.visibility_level === 'built_in' }
|
|
68
|
+
: undefined
|
|
69
|
+
setSubmitEnabled(true)
|
|
70
|
+
}}
|
|
71
|
+
data={ag => ({
|
|
72
|
+
idOrSlug: ag.id,
|
|
73
|
+
image: ag.avatar ? <img src={ag.avatar} /> : <Icon icon="Agent" />,
|
|
74
|
+
description: <AgentDescription agentId={ag.id} />,
|
|
75
|
+
name: ag.name,
|
|
76
|
+
listFavorites,
|
|
77
|
+
onAddFavorite,
|
|
78
|
+
onRemoveFavorite,
|
|
79
|
+
})}
|
|
80
|
+
emptyResults={
|
|
81
|
+
<Placeholder title={t.noSearchResults} description={t.noSearchResultsDescription} className="no-data-placeholder" />
|
|
82
|
+
}
|
|
83
|
+
emptyDataset={<Placeholder title={t.noData} description={t.noDataDescription} />}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
{!!agents?.length && showSubmitButton && <Button onClick={submit} disabled={!submitEnabled}>{t.apply}</Button>}
|
|
87
|
+
</>
|
|
81
88
|
)
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { agentToolsClient } from '@stack-spot/portal-network'
|
|
3
3
|
|
|
4
4
|
export function useAgentFavorites() {
|
|
5
|
-
const useFavorites = () => agentToolsClient.
|
|
5
|
+
const useFavorites = () => agentToolsClient.agentsMultipleFilters.useQuery({ filters: { visibility_list: ['favorite'] } })?.items
|
|
6
6
|
const [addFavorite, pendingAddFav] = agentToolsClient.addFavorite.useMutation()
|
|
7
7
|
const [removeFavorite, pendingRemoveFav] = agentToolsClient.removeFavorite.useMutation()
|
|
8
8
|
|
|
9
9
|
const removeFavoriteAgent = async (idOrSlug?: string) => {
|
|
10
10
|
try {
|
|
11
11
|
await removeFavorite({ agentId: idOrSlug || '' })
|
|
12
|
-
await agentToolsClient.
|
|
12
|
+
await agentToolsClient.agentsMultipleFilters.invalidate({ filters: { visibility_list: ['favorite'] } })
|
|
13
13
|
} catch (error) {
|
|
14
14
|
// eslint-disable-next-line no-console
|
|
15
15
|
console.error(error)
|
|
@@ -19,7 +19,7 @@ export function useAgentFavorites() {
|
|
|
19
19
|
const addFavoriteAgent = async (idOrSlug?: string) => {
|
|
20
20
|
try {
|
|
21
21
|
await addFavorite({ agentId: idOrSlug || '' })
|
|
22
|
-
await agentToolsClient.
|
|
22
|
+
await agentToolsClient.agentsMultipleFilters.invalidate({ filters: { visibility_list: ['favorite'] } })
|
|
23
23
|
} catch (error) {
|
|
24
24
|
// eslint-disable-next-line no-console
|
|
25
25
|
console.error(error)
|
|
@@ -50,14 +50,14 @@ const StepAccordionHeader = ({ step, index, expand }: Pick<StepProps, 'step' | '
|
|
|
50
50
|
return <Row gap="8px">
|
|
51
51
|
{expand}
|
|
52
52
|
{step.status === 'target' ? <Text className="step-title" appearance="body2" color="light.700">{t.planGoal}:</Text> :
|
|
53
|
-
<Badge colorScheme="inverse" appearance="square">
|
|
53
|
+
<Badge colorScheme="inverse" appearance="square" style={{ whiteSpace: 'nowrap' }}>
|
|
54
54
|
{t.step} {index}
|
|
55
55
|
</Badge>}
|
|
56
56
|
<Text className="step-title" appearance="body2">
|
|
57
57
|
{step.input}
|
|
58
58
|
</Text>
|
|
59
59
|
{step.status === 'awaiting_approval' &&
|
|
60
|
-
<Badge appearance="square" style={{ backgroundColor: theme.color.gray[800], color: theme.color.gray[50] }}>
|
|
60
|
+
<Badge appearance="square" style={{ backgroundColor: theme.color.gray[800], color: theme.color.gray[50], whiteSpace: 'nowrap' }}>
|
|
61
61
|
<Icon icon="Security" />
|
|
62
62
|
{t.pendingReview}
|
|
63
63
|
</Badge>}
|
|
@@ -199,7 +199,7 @@ export const ToolStepsList = ({ toolStep, messageId, chatId }: { toolStep: ToolC
|
|
|
199
199
|
return <>
|
|
200
200
|
{toolStep && tool ? <AnimatedHeight>
|
|
201
201
|
<div className="steps">
|
|
202
|
-
<Badge colorPalette="yellow" appearance="square">
|
|
202
|
+
<Badge colorPalette="yellow" appearance="square" style={{ whiteSpace: 'nowrap' }}>
|
|
203
203
|
<Icon icon="StopWatch" />
|
|
204
204
|
<Text>{tool.name} {t.keepWorking}</Text>
|
|
205
205
|
</Badge>
|
|
@@ -305,7 +305,7 @@ export const StepsList = ({ steps, messageId, chatId, userHasAlreadyAnswered }:
|
|
|
305
305
|
{!userHasAlreadyAnswered && planning?.[0]?.status === 'awaiting_approval' && <AwaitingApproval chatId={chatId} />}
|
|
306
306
|
</Column>
|
|
307
307
|
|
|
308
|
-
{userHasAlreadyAnswered && planning?.[0]?.status === 'success' && <ViewToolsDetails chatId={chatId} />}
|
|
308
|
+
{userHasAlreadyAnswered && planning?.[0]?.status === 'success' && <ViewToolsDetails chatId={chatId} messageId={messageId}/>}
|
|
309
309
|
|
|
310
310
|
</div>
|
|
311
311
|
</AnimatedHeight> : null}
|
|
@@ -316,14 +316,15 @@ export const StepsList = ({ steps, messageId, chatId, userHasAlreadyAnswered }:
|
|
|
316
316
|
)
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
export const ViewToolsDetails = ({ chatId }: { chatId: string }) => {
|
|
319
|
+
export const ViewToolsDetails = ({ chatId, messageId }: { chatId: string, messageId: number }) => {
|
|
320
320
|
const t = useTranslate(dictionary)
|
|
321
321
|
const messages = useChatMessages(chatId)
|
|
322
322
|
const widget = useWidget()
|
|
323
323
|
const getPlanningMessageId = () => {
|
|
324
|
+
const messageStep= messages[messageId]?.getValue().steps?.find((step) => step.type === 'step')
|
|
324
325
|
const messageWithPlanning = findLast(messages, (message) => {
|
|
325
326
|
const steps = message.getValue().steps
|
|
326
|
-
const planningStep = steps?.find((step) => step.
|
|
327
|
+
const planningStep = steps?.find((step) => step.id === messageStep?.id)
|
|
327
328
|
return planningStep ? true : false
|
|
328
329
|
})
|
|
329
330
|
return messageWithPlanning?.id
|
|
@@ -15,7 +15,8 @@ export const ModelSwitcher = () => {
|
|
|
15
15
|
const chat = useCurrentChat()
|
|
16
16
|
const [filter, setFilter] = useState('')
|
|
17
17
|
const [visibleMenu, setVisibleMenu] = useState(false)
|
|
18
|
-
const [agentData, isLoadingAgentData] = agentToolsClient.agent.useStatefulQuery({ agentId: agentCurrentChat?.id || '' }
|
|
18
|
+
const [agentData, isLoadingAgentData] = agentToolsClient.agent.useStatefulQuery({ agentId: agentCurrentChat?.id || '' },
|
|
19
|
+
{ enabled: !!agentCurrentChat?.id })
|
|
19
20
|
const [models, isLoadingModels] =
|
|
20
21
|
genAiInferenceClient.listModels.useStatefulQuery({ pageSize: 999, active: true })
|
|
21
22
|
|