@budibase/frontend-core 3.24.6 → 3.24.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "3.24.
|
|
3
|
+
"version": "3.24.8",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"@budibase/types": "*",
|
|
15
15
|
"ai": "^6.0.3",
|
|
16
16
|
"dayjs": "^1.10.8",
|
|
17
|
-
"lodash": "4.17.
|
|
17
|
+
"lodash": "4.17.23",
|
|
18
18
|
"shortid": "2.2.15",
|
|
19
19
|
"socket.io-client": "^4.7.5"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "58df0d7f5042ed129b7b340575d4c94ea19ef498"
|
|
22
22
|
}
|
package/src/api/aiConfig.ts
CHANGED
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
CustomAIProviderConfig,
|
|
4
4
|
CreateAIConfigRequest,
|
|
5
5
|
UpdateAIConfigRequest,
|
|
6
|
+
LLMProvidersResponse,
|
|
6
7
|
} from "@budibase/types"
|
|
7
8
|
|
|
8
9
|
import { BaseAPIClient } from "./types"
|
|
9
10
|
|
|
10
11
|
export interface AIConfigEndpoints {
|
|
11
12
|
fetch: () => Promise<AIConfigListResponse>
|
|
13
|
+
providers: () => Promise<LLMProvidersResponse>
|
|
12
14
|
create: (config: CreateAIConfigRequest) => Promise<CustomAIProviderConfig>
|
|
13
15
|
update: (config: UpdateAIConfigRequest) => Promise<CustomAIProviderConfig>
|
|
14
16
|
delete: (id: string) => Promise<{ deleted: true }>
|
|
@@ -23,6 +25,12 @@ export const buildAIConfigEndpoints = (
|
|
|
23
25
|
})
|
|
24
26
|
},
|
|
25
27
|
|
|
28
|
+
providers: async () => {
|
|
29
|
+
return await API.get({
|
|
30
|
+
url: `/api/configs/providers`,
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
|
|
26
34
|
create: async config => {
|
|
27
35
|
return await API.post({
|
|
28
36
|
url: `/api/configs`,
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
export let chat: ChatConversationLike
|
|
30
30
|
export let loading: boolean = false
|
|
31
|
+
export let persistConversation: boolean = true
|
|
31
32
|
|
|
32
33
|
const dispatch = createEventDispatcher<{
|
|
33
34
|
chatSaved: { chatId?: string; chat: ChatConversationLike }
|
|
@@ -107,7 +108,11 @@
|
|
|
107
108
|
return
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
if (
|
|
111
|
+
if (
|
|
112
|
+
persistConversation &&
|
|
113
|
+
!chat._id &&
|
|
114
|
+
(!chat.messages || chat.messages.length === 0)
|
|
115
|
+
) {
|
|
111
116
|
try {
|
|
112
117
|
const newChat = await API.createChatConversation(
|
|
113
118
|
{
|
|
@@ -141,6 +146,7 @@
|
|
|
141
146
|
const updatedChat: ChatConversationLike = {
|
|
142
147
|
...chat,
|
|
143
148
|
chatAppId: chat.chatAppId,
|
|
149
|
+
transient: !persistConversation,
|
|
144
150
|
messages: [...chat.messages, userMessage],
|
|
145
151
|
}
|
|
146
152
|
|
|
@@ -157,33 +163,42 @@
|
|
|
157
163
|
)
|
|
158
164
|
|
|
159
165
|
let streamedMessages = [...updatedChat.messages]
|
|
166
|
+
let transientAssistantId = uuidv4()
|
|
160
167
|
|
|
161
168
|
for await (const message of messageStream) {
|
|
162
|
-
|
|
169
|
+
const normalizedMessage =
|
|
170
|
+
!persistConversation && message?.role === "assistant" && !message?.id
|
|
171
|
+
? {
|
|
172
|
+
...message,
|
|
173
|
+
id: transientAssistantId,
|
|
174
|
+
}
|
|
175
|
+
: message
|
|
176
|
+
|
|
177
|
+
if (normalizedMessage?.id) {
|
|
163
178
|
const existingIndex = streamedMessages.findIndex(
|
|
164
|
-
existing => existing.id ===
|
|
179
|
+
existing => existing.id === normalizedMessage.id
|
|
165
180
|
)
|
|
166
181
|
if (existingIndex !== -1) {
|
|
167
182
|
streamedMessages = streamedMessages.map((existing, index) =>
|
|
168
|
-
index === existingIndex ?
|
|
183
|
+
index === existingIndex ? normalizedMessage : existing
|
|
169
184
|
)
|
|
170
185
|
} else {
|
|
171
|
-
streamedMessages = [...streamedMessages,
|
|
186
|
+
streamedMessages = [...streamedMessages, normalizedMessage]
|
|
172
187
|
}
|
|
173
|
-
} else if (
|
|
188
|
+
} else if (normalizedMessage?.role === "assistant") {
|
|
174
189
|
const lastIndex = [...streamedMessages]
|
|
175
190
|
.reverse()
|
|
176
191
|
.findIndex(existing => existing.role === "assistant")
|
|
177
192
|
if (lastIndex !== -1) {
|
|
178
193
|
const targetIndex = streamedMessages.length - 1 - lastIndex
|
|
179
194
|
streamedMessages = streamedMessages.map((existing, index) =>
|
|
180
|
-
index === targetIndex ?
|
|
195
|
+
index === targetIndex ? normalizedMessage : existing
|
|
181
196
|
)
|
|
182
197
|
} else {
|
|
183
|
-
streamedMessages = [...streamedMessages,
|
|
198
|
+
streamedMessages = [...streamedMessages, normalizedMessage]
|
|
184
199
|
}
|
|
185
200
|
} else {
|
|
186
|
-
streamedMessages = [...streamedMessages,
|
|
201
|
+
streamedMessages = [...streamedMessages, normalizedMessage]
|
|
187
202
|
}
|
|
188
203
|
chat = {
|
|
189
204
|
...updatedChat,
|
|
@@ -195,7 +210,7 @@
|
|
|
195
210
|
// When a chat is created for the first time the server generates the ID.
|
|
196
211
|
// If we don't have it locally yet, retrieve the saved conversation so
|
|
197
212
|
// subsequent prompts append to the same document instead of creating a new one.
|
|
198
|
-
if (!chat._id && chat.chatAppId) {
|
|
213
|
+
if (persistConversation && !chat._id && chat.chatAppId) {
|
|
199
214
|
try {
|
|
200
215
|
const history = await API.fetchChatHistory(chat.chatAppId)
|
|
201
216
|
const lastMessageId = chat.messages[chat.messages.length - 1]?.id
|
|
@@ -419,8 +434,6 @@
|
|
|
419
434
|
position: sticky;
|
|
420
435
|
bottom: 0;
|
|
421
436
|
width: 100%;
|
|
422
|
-
background: var(--background-alt);
|
|
423
|
-
padding-bottom: 32px;
|
|
424
437
|
display: flex;
|
|
425
438
|
flex-direction: column;
|
|
426
439
|
}
|
|
@@ -438,7 +451,6 @@
|
|
|
438
451
|
border: none;
|
|
439
452
|
outline: none;
|
|
440
453
|
min-height: 100px;
|
|
441
|
-
margin-bottom: 8px;
|
|
442
454
|
}
|
|
443
455
|
|
|
444
456
|
.input::placeholder {
|