@stack-spot/ai-chat-widget 2.4.0 → 2.4.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 +16 -0
- package/dist/app-metadata.json +5 -5
- package/dist/chat-interceptors/send-message.d.ts +16 -1
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +148 -138
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/features.d.ts +4 -0
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +1 -0
- package/dist/features.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/state/ChatEntry.d.ts +13 -1
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/views/Agents/styled.d.ts.map +1 -1
- package/dist/views/Agents/styled.js +1 -2
- package/dist/views/Agents/styled.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +7 -4
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/StepsList.js +5 -5
- 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 +4 -8
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/MessageInput/ButtonBar.js +1 -1
- package/dist/views/MessageInput/ButtonBar.js.map +1 -1
- package/dist/views/Resources.js +12 -5
- package/dist/views/Resources.js.map +1 -1
- package/package.json +4 -4
- package/src/app-metadata.json +5 -5
- package/src/chat-interceptors/send-message.ts +163 -149
- package/src/features.ts +8 -3
- package/src/index.ts +2 -0
- package/src/state/ChatEntry.ts +19 -7
- package/src/views/Agents/styled.ts +1 -2
- package/src/views/Chat/ChatMessage.tsx +50 -60
- package/src/views/Chat/StepsList.tsx +8 -8
- package/src/views/Chat/styled.ts +4 -8
- package/src/views/MessageInput/ButtonBar.tsx +1 -1
- package/src/views/MessageInput/index.tsx +2 -2
- package/src/views/Resources.tsx +18 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentInfo, aiClient, ChatResponseWithSteps, ChatStep, StackspotAPIError, StreamCanceledError } from '@stack-spot/portal-network'
|
|
1
|
+
import { AgentInfo, aiClient, ChatResponseWithPMResources, ChatResponseWithSteps, ChatStep, StackspotAPIError, StreamCanceledError } from '@stack-spot/portal-network'
|
|
2
2
|
import { ChatResponse3 } from '@stack-spot/portal-network/api/ai'
|
|
3
3
|
import { findLast } from 'lodash'
|
|
4
4
|
import { ChatEntry, KnowledgeSource, TextChatEntry } from '../state/ChatEntry'
|
|
@@ -18,13 +18,13 @@ import { planningToolDictionaryHelper } from '../utils/planning-tool'
|
|
|
18
18
|
* @param includeDate whether or not to include the date in the chat entry.
|
|
19
19
|
* @returns the TextChatEntry to build a ChatEntry.
|
|
20
20
|
*/
|
|
21
|
-
function createEntryValueFromChatResponse(
|
|
22
|
-
response: Partial<ChatResponseWithSteps
|
|
21
|
+
export function createEntryValueFromChatResponse(
|
|
22
|
+
response: Partial<ChatResponseWithSteps> & ChatResponseWithPMResources,
|
|
23
23
|
knowledgeSources: KnowledgeSource[] | undefined,
|
|
24
24
|
agent: LabeledWithImage | undefined,
|
|
25
25
|
includeDate = false,
|
|
26
26
|
): TextChatEntry {
|
|
27
|
-
const entry= {
|
|
27
|
+
const entry = {
|
|
28
28
|
agentType: 'bot',
|
|
29
29
|
type: 'md',
|
|
30
30
|
content: response.answer ?? '',
|
|
@@ -34,6 +34,9 @@ function createEntryValueFromChatResponse(
|
|
|
34
34
|
updated: includeDate ? new Date().toISOString() : undefined,
|
|
35
35
|
steps: response.steps,
|
|
36
36
|
tools: response.tools,
|
|
37
|
+
opportunities: response.opportunities,
|
|
38
|
+
hypothesis: response.hypothesis,
|
|
39
|
+
prfaq: response.prfaq,
|
|
37
40
|
}
|
|
38
41
|
return entry as TextChatEntry
|
|
39
42
|
}
|
|
@@ -43,32 +46,11 @@ function buildPrompt(content: string, data?: any) {
|
|
|
43
46
|
return typeof data === 'string' ? data : JSON.stringify(data)
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* The message added to the chat is streamed, i.e. it changes over time, until it's completed.
|
|
50
|
-
*
|
|
51
|
-
* @param entry the chat entry.
|
|
52
|
-
* @param chat the chat state.
|
|
53
|
-
* @param signal a signal that can be canceled by the user.
|
|
54
|
-
* @returns undefined
|
|
55
|
-
*/
|
|
56
|
-
export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState, signal: AbortSignal) {
|
|
57
|
-
const { agentType, content, data } = entry.getValue()
|
|
58
|
-
if (agentType !== 'user') return
|
|
59
|
-
const context = buildConversationContext(chat, entry)
|
|
60
|
-
chat.set('isLoading', true)
|
|
61
|
-
const untitled = chat.untitled
|
|
62
|
-
const isFirstMessage = chat.getMessages().length === 1
|
|
63
|
-
if (untitled) {
|
|
64
|
-
chat.set('label', content || entry.getValue().upload?.[0]?.name || 'Chat')
|
|
65
|
-
chat.untitled = false
|
|
66
|
-
}
|
|
67
|
-
|
|
49
|
+
//Verify if the last planning in the messages has status awaiting_approval
|
|
50
|
+
const getLastPlanningAwaiting = (chat: ChatState) => {
|
|
68
51
|
const messages = chat.getMessages()
|
|
69
52
|
|
|
70
|
-
|
|
71
|
-
const getLastPlanningAwaiting = () => findLast(messages, item => {
|
|
53
|
+
return findLast(messages, item => {
|
|
72
54
|
const steps = item.getValue().steps
|
|
73
55
|
if (steps) {
|
|
74
56
|
const hasPlanning = steps.find((step) => step.type === 'planning')
|
|
@@ -76,157 +58,189 @@ export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState,
|
|
|
76
58
|
}
|
|
77
59
|
return false
|
|
78
60
|
})
|
|
61
|
+
}
|
|
79
62
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
// we add the chat entry and show the streaming if the streaming feature is enabled
|
|
84
|
-
if (chat.get('features').streaming) {
|
|
85
|
-
chat.pushMessage(botEntry)
|
|
86
|
-
}
|
|
87
|
-
let knowledgeSources: KnowledgeSource[] | undefined
|
|
88
|
-
|
|
89
|
-
const updatePlanningMessage = () => {
|
|
90
|
-
const lastPlanningAwaiting = getLastPlanningAwaiting()
|
|
63
|
+
const updateToolStatus = (agentInfo: AgentInfo, chat: ChatState) => {
|
|
64
|
+
const executionId = agentInfo.id
|
|
65
|
+
const messages = chat.getMessages()
|
|
91
66
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
67
|
+
if (executionId) {
|
|
68
|
+
//Update message with type step which contains the planning steps
|
|
69
|
+
const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(executionId)
|
|
70
|
+
const originalItem = messages.find((message) => `${message.id}` === messageId)
|
|
71
|
+
const originalItemValue = originalItem?.getValue()
|
|
72
|
+
let update = false
|
|
73
|
+
const status = agentInfo.action === 'start' ? 'running' : 'success'
|
|
74
|
+
const step = originalItemValue?.steps
|
|
75
|
+
?.find(step => step.type === 'step' && step.attempts?.[0]?.tools?.[0]?.executionId === executionId)
|
|
76
|
+
if (step && step.status !== status) {
|
|
77
|
+
step.status = status
|
|
78
|
+
update = true
|
|
79
|
+
}
|
|
80
|
+
if (update) {
|
|
100
81
|
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
101
82
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const updateStepMessage = (step: ChatStep) => {
|
|
105
|
-
const lastPlanningAwaiting = getLastPlanningAwaiting()
|
|
106
83
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
//Updates message with type tool which contains the actually tool steps
|
|
85
|
+
//We only want to show tools banner when they are awaiting_approval, by removing the step
|
|
86
|
+
// we avoid the entire bot message to be visible
|
|
87
|
+
const toolMessageId = planningToolDictionaryHelper.getMessageIdToolStepFromToolExecutionId(executionId)
|
|
88
|
+
const toolOriginalItem = messages.find((message) => `${message.id}` === toolMessageId)
|
|
89
|
+
const toolOriginalItemValue = toolOriginalItem?.getValue()
|
|
90
|
+
const toolStep = toolOriginalItemValue?.steps?.find(step =>
|
|
91
|
+
step.type === 'tool' && step.attempts?.[0]?.tools?.[0]?.executionId === executionId)
|
|
92
|
+
update = false
|
|
93
|
+
if (toolOriginalItemValue && toolStep && toolStep.status !== status) {
|
|
94
|
+
toolOriginalItemValue.steps = undefined
|
|
95
|
+
update = true
|
|
96
|
+
}
|
|
97
|
+
if (update) {
|
|
98
|
+
toolOriginalItem?.setValue({ ...toolOriginalItemValue as TextChatEntry })
|
|
116
99
|
}
|
|
117
100
|
}
|
|
101
|
+
}
|
|
118
102
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
//Update message with type step which contains the planning steps
|
|
123
|
-
const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(executionId)
|
|
124
|
-
const originalItem = messages.find((message) => `${message.id}` === messageId)
|
|
125
|
-
const originalItemValue = originalItem?.getValue()
|
|
126
|
-
let update = false
|
|
127
|
-
const status = agentInfo.action === 'start' ? 'running' : 'success'
|
|
128
|
-
const step = originalItemValue?.steps
|
|
129
|
-
?.find(step => step.type === 'step' && step.attempts?.[0].tools?.[0]?.executionId === executionId)
|
|
130
|
-
if (step && step.status !== status) {
|
|
131
|
-
step.status = status
|
|
132
|
-
update = true
|
|
133
|
-
}
|
|
134
|
-
if (update) {
|
|
135
|
-
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
136
|
-
}
|
|
103
|
+
const updateStepMessage = (step: ChatStep, chat: ChatState) => {
|
|
104
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(chat)
|
|
105
|
+
const messages = chat.getMessages()
|
|
137
106
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const toolStep = toolOriginalItemValue?.steps?.find(step =>
|
|
145
|
-
step.type === 'tool' && step.attempts?.[0].tools?.[0]?.executionId === executionId)
|
|
146
|
-
update = false
|
|
147
|
-
if (toolOriginalItemValue && toolStep && toolStep.status !== status) {
|
|
148
|
-
toolOriginalItemValue.steps = undefined
|
|
149
|
-
update = true
|
|
150
|
-
}
|
|
151
|
-
if (update) {
|
|
152
|
-
toolOriginalItem?.setValue({ ...toolOriginalItemValue as TextChatEntry })
|
|
107
|
+
if (lastPlanningAwaiting) {
|
|
108
|
+
const originalItem = messages.find((message) => message.id === lastPlanningAwaiting.id)
|
|
109
|
+
const originalItemValue = originalItem?.getValue()
|
|
110
|
+
originalItemValue?.steps?.filter((messageStep) => {
|
|
111
|
+
if (messageStep.id === step.id) {
|
|
112
|
+
messageStep = { ...step }
|
|
153
113
|
}
|
|
154
|
-
}
|
|
114
|
+
})
|
|
115
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
155
116
|
}
|
|
117
|
+
}
|
|
156
118
|
|
|
157
|
-
stream.onChange(value => {
|
|
158
|
-
if (value.agent_info?.type === 'planning') {
|
|
159
|
-
if (value.agent_info.action === 'start') {
|
|
160
|
-
chat.set('isPlaning', true)
|
|
161
|
-
} else {
|
|
162
|
-
chat.set('isPlaning', false)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
119
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
120
|
+
const updatePlanningMessage = (chat: ChatState) => {
|
|
121
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(chat)
|
|
122
|
+
const messages = chat.getMessages()
|
|
123
|
+
|
|
124
|
+
if (lastPlanningAwaiting) {
|
|
125
|
+
const originalItem = messages.find((message) => message.id === lastPlanningAwaiting.id)
|
|
126
|
+
const originalItemValue = originalItem?.getValue()
|
|
127
|
+
originalItemValue?.steps?.map((step) => {
|
|
128
|
+
if (step.type === 'planning' && step.status === 'awaiting_approval') {
|
|
129
|
+
step.status = 'success'
|
|
171
130
|
}
|
|
172
|
-
}
|
|
131
|
+
})
|
|
132
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
133
|
+
}
|
|
134
|
+
}
|
|
173
135
|
|
|
174
|
-
|
|
175
|
-
|
|
136
|
+
export function helperSendMessage(value: Partial<ChatResponseWithSteps> & { opportunities?: any },
|
|
137
|
+
chat: ChatState, botEntry: ChatEntry, knowledgeSources: KnowledgeSource[] | undefined) {
|
|
138
|
+
const messages = chat.getMessages()
|
|
139
|
+
if (value.agent_info?.type === 'planning') {
|
|
140
|
+
if (value.agent_info.action === 'start') {
|
|
141
|
+
chat.set('isPlaning', true)
|
|
142
|
+
} else {
|
|
143
|
+
chat.set('isPlaning', false)
|
|
176
144
|
}
|
|
145
|
+
}
|
|
177
146
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
} else if (step.type === 'step') {
|
|
184
|
-
updateStepMessage(step)
|
|
185
|
-
}
|
|
186
|
-
})
|
|
147
|
+
if (value.agent_info?.type === 'chat' && value.agent_info?.action === 'end') {
|
|
148
|
+
//When an error happens, the step can still be running, so we enforce the error
|
|
149
|
+
const stepRunning = findLast(value.steps, (item) => item.status === 'running')
|
|
150
|
+
if (stepRunning?.status) {
|
|
151
|
+
stepRunning.status = 'error'
|
|
187
152
|
}
|
|
153
|
+
}
|
|
188
154
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
155
|
+
if (value.sources?.length !== knowledgeSources?.length && chat.get('features').showSourcesInResponse) {
|
|
156
|
+
knowledgeSources = genericSourcesToKnowledgeSources(value.sources)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(chat)
|
|
160
|
+
if (lastPlanningAwaiting && value.steps) {
|
|
161
|
+
value.steps?.map(step => {
|
|
162
|
+
if (step.type === 'planning') {
|
|
163
|
+
updatePlanningMessage(chat)
|
|
164
|
+
} else if (step.type === 'step') {
|
|
165
|
+
updateStepMessage(step, chat)
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (value.agent_info?.type === 'tool' && value.agent_info?.action !== 'awaiting_approval') {
|
|
171
|
+
updateToolStatus(value.agent_info, chat)
|
|
172
|
+
}
|
|
192
173
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
})
|
|
174
|
+
if (value.steps) {
|
|
175
|
+
const tool = findLast(value.steps, (item) => item.type === 'tool')
|
|
176
|
+
if (tool && tool.status === 'running') {
|
|
177
|
+
const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(tool.id)
|
|
178
|
+
const originalItem = messages.find((message) => `${message.id}` === messageId)
|
|
179
|
+
const originalItemValue = originalItem?.getValue()
|
|
180
|
+
let update = false
|
|
181
|
+
const step = originalItemValue?.steps?.find(step => step.type === 'step')
|
|
182
|
+
if (step && step.attempts?.[0]?.tools?.[0]?.executionId === tool.id) {
|
|
183
|
+
step.attempts?.forEach((attempt, i) => {
|
|
184
|
+
const newAttempt = tool.attempts?.[i]
|
|
185
|
+
if (!newAttempt) return
|
|
186
|
+
attempt.tools = attempt.tools?.map((origTool, j) => {
|
|
187
|
+
const newTool = newAttempt.tools?.[j]
|
|
188
|
+
if (!newTool || origTool?.executionId !== newTool?.executionId) return origTool
|
|
189
|
+
update = true
|
|
190
|
+
return { ...origTool, ...newTool }
|
|
211
191
|
})
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
if (update) {
|
|
217
|
-
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
192
|
+
})
|
|
193
|
+
if (step.attempts.length < tool.attempts.length) {
|
|
194
|
+
step.attempts.push(tool.attempts[tool.attempts.length - 1])
|
|
218
195
|
}
|
|
219
196
|
}
|
|
197
|
+
if (update) {
|
|
198
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
199
|
+
}
|
|
220
200
|
}
|
|
201
|
+
}
|
|
221
202
|
|
|
222
|
-
|
|
223
|
-
|
|
203
|
+
botEntry.setValue(createEntryValueFromChatResponse(value, knowledgeSources, chat.get('agent')))
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The chat interceptor that sends the message to the AI agent, interprets the response and adds it to the chat.
|
|
208
|
+
*
|
|
209
|
+
* The message added to the chat is streamed, i.e. it changes over time, until it's completed.
|
|
210
|
+
*
|
|
211
|
+
* @param entry the chat entry.
|
|
212
|
+
* @param chat the chat state.
|
|
213
|
+
* @param signal a signal that can be canceled by the user.
|
|
214
|
+
* @returns undefined
|
|
215
|
+
*/
|
|
216
|
+
export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState, signal: AbortSignal) {
|
|
217
|
+
const { agentType, content, data } = entry.getValue()
|
|
218
|
+
if (agentType !== 'user') return
|
|
219
|
+
const context = buildConversationContext(chat, entry)
|
|
220
|
+
chat.set('isLoading', true)
|
|
221
|
+
const untitled = chat.untitled
|
|
222
|
+
const isFirstMessage = chat.getMessages().length === 1
|
|
223
|
+
if (untitled) {
|
|
224
|
+
chat.set('label', content || entry.getValue().upload?.[0]?.name || 'Chat')
|
|
225
|
+
chat.untitled = false
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const stream = aiClient.sendChatMessage({ context, user_prompt: buildPrompt(content, data) })
|
|
229
|
+
signal.addEventListener('abort', () => stream.cancel())
|
|
230
|
+
const botEntry = ChatEntry.createStreamedBotEntry()
|
|
231
|
+
// we add the chat entry and show the streaming if the streaming feature is enabled
|
|
232
|
+
if (chat.get('features').streaming) {
|
|
233
|
+
chat.pushMessage(botEntry)
|
|
234
|
+
}
|
|
235
|
+
let knowledgeSources: KnowledgeSource[] | undefined
|
|
236
|
+
|
|
237
|
+
stream.onChange(value => helperSendMessage(value, chat, botEntry, knowledgeSources))
|
|
224
238
|
|
|
225
239
|
let finalValue: Partial<ChatResponse3> | undefined
|
|
226
240
|
try {
|
|
227
241
|
finalValue = await stream.getValue()
|
|
228
242
|
|
|
229
|
-
const lastPlanningAwaiting = getLastPlanningAwaiting()
|
|
243
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(chat)
|
|
230
244
|
if (lastPlanningAwaiting) {
|
|
231
245
|
const value = lastPlanningAwaiting.getValue()
|
|
232
246
|
value.content = finalValue.answer || value.content
|
package/src/features.ts
CHANGED
|
@@ -39,6 +39,10 @@ export interface ChatFeatures {
|
|
|
39
39
|
* Enables streaming in chat responses.
|
|
40
40
|
*/
|
|
41
41
|
streaming: boolean,
|
|
42
|
+
/**
|
|
43
|
+
* Enables LLM select.
|
|
44
|
+
*/
|
|
45
|
+
showLLMSelect: boolean,
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
export type Scope = 'favorite' | 'builtin' | 'personal' | 'shared' | 'workspace' | 'account'
|
|
@@ -54,9 +58,9 @@ export interface GlobalFeatures {
|
|
|
54
58
|
* If this is set, only the scopes in this list will be enabled.
|
|
55
59
|
*/
|
|
56
60
|
scopes?: Scope[],
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
/**
|
|
62
|
+
* When set, only items(knowledge sources, agents, stacks ai, quick commands) from that workspace will be shown to the user.
|
|
63
|
+
*/
|
|
60
64
|
workspaceId?: string,
|
|
61
65
|
/**
|
|
62
66
|
* when set to false it does not show tab by scope, it shows a single list.
|
|
@@ -83,6 +87,7 @@ export function getFeaturesWithDefaults(features?: Partial<AIWidgetFeatures>): A
|
|
|
83
87
|
messageInput: true,
|
|
84
88
|
upload: true,
|
|
85
89
|
streaming: true,
|
|
90
|
+
showLLMSelect: true,
|
|
86
91
|
showSourcesInResponse: true,
|
|
87
92
|
groupResourcesByScope: true,
|
|
88
93
|
...features,
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
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
|
+
|
|
4
|
+
export { createEntryValueFromChatResponse, helperSendMessage } from './chat-interceptors/send-message'
|
|
3
5
|
export { QuickStartButton } from './components/QuickStartButton'
|
|
4
6
|
export { AIWidgetProvider } from './context/AIWidgetProvider'
|
|
5
7
|
export * from './context/hooks'
|
package/src/state/ChatEntry.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ChatStep } from '@stack-spot/portal-network'
|
|
1
|
+
import { ChatStep, HypothesisPMAgent, OpportunitiesPMAgent, PrfaqPMAgent } from '@stack-spot/portal-network'
|
|
2
2
|
import { ColorPaletteName, ColorSchemeName } from '@stack-spot/portal-theme'
|
|
3
3
|
import { pull } from 'lodash'
|
|
4
4
|
import { LabeledAgent } from './types'
|
|
5
5
|
|
|
6
6
|
export interface ActionDataClick {
|
|
7
|
-
name?: string,
|
|
7
|
+
name?: string,
|
|
8
8
|
value?: string[],
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -44,9 +44,9 @@ export interface ChatAction extends SerializableAction {
|
|
|
44
44
|
* @default button
|
|
45
45
|
*/
|
|
46
46
|
buttonType?: 'submit' | 'button',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @default lg
|
|
49
|
+
*/
|
|
50
50
|
size?: 'lg' | 'md' | 'sm',
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -146,10 +146,22 @@ export interface TextChatEntry {
|
|
|
146
146
|
* If any tool was used to generate the response, its id is returned in this list.
|
|
147
147
|
*/
|
|
148
148
|
tools?: string[],
|
|
149
|
+
/**
|
|
150
|
+
* If opportunities exists in pm agent, its send in this list.
|
|
151
|
+
*/
|
|
152
|
+
opportunities?: OpportunitiesPMAgent[],
|
|
153
|
+
/**
|
|
154
|
+
* If hypothesis exists in pm agent, its send in this list.
|
|
155
|
+
*/
|
|
156
|
+
hypothesis?: HypothesisPMAgent[],
|
|
157
|
+
/**
|
|
158
|
+
* If prfaq exists in pm agent, its send in this object.
|
|
159
|
+
*/
|
|
160
|
+
prfaq?: PrfaqPMAgent,
|
|
149
161
|
/*
|
|
150
162
|
* Options for radio, checkbox or button type.
|
|
151
163
|
*/
|
|
152
|
-
options?: { color?: ColorSchemeName, label: string, value?: string, hasInput?: boolean}[],
|
|
164
|
+
options?: { color?: ColorSchemeName, label: string, value?: string, hasInput?: boolean }[],
|
|
153
165
|
/**
|
|
154
166
|
* Name to be used in input type fields.
|
|
155
167
|
*/
|
|
@@ -211,7 +223,7 @@ export class ChatEntry {
|
|
|
211
223
|
type: isMd ? 'md' : 'text',
|
|
212
224
|
content,
|
|
213
225
|
name: fieldName,
|
|
214
|
-
hiddenContent,
|
|
226
|
+
hiddenContent,
|
|
215
227
|
data,
|
|
216
228
|
updated: new Date().toISOString(),
|
|
217
229
|
})
|