@budibase/frontend-core 3.24.4 → 3.24.6
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.6",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"shortid": "2.2.15",
|
|
19
19
|
"socket.io-client": "^4.7.5"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "e346f36cee24c74adbfeb31800d5b9f3ebe692c0"
|
|
22
22
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { MarkdownViewer, notifications } from "@budibase/bbui"
|
|
3
3
|
import type {
|
|
4
|
-
AgentMessageMetadata,
|
|
5
4
|
ChatConversation,
|
|
5
|
+
DraftChatConversation,
|
|
6
|
+
AgentMessageMetadata,
|
|
6
7
|
ChatConversationRequest,
|
|
7
8
|
} from "@budibase/types"
|
|
8
9
|
import { Header } from "@budibase/shared-core"
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
26
|
})
|
|
26
|
-
type ChatConversationLike = ChatConversation |
|
|
27
|
+
type ChatConversationLike = ChatConversation | DraftChatConversation
|
|
27
28
|
|
|
28
29
|
export let chat: ChatConversationLike
|
|
29
30
|
export let loading: boolean = false
|
|
@@ -50,10 +51,19 @@
|
|
|
50
51
|
try {
|
|
51
52
|
const chatApp = await API.fetchChatApp(workspaceId)
|
|
52
53
|
if (chatApp?._id) {
|
|
53
|
-
const baseChat = chat || {
|
|
54
|
+
const baseChat = chat || {
|
|
55
|
+
title: "",
|
|
56
|
+
messages: [],
|
|
57
|
+
chatAppId: "",
|
|
58
|
+
agentId: "",
|
|
59
|
+
}
|
|
60
|
+
const fallbackAgentId = chatApp.enabledAgents?.[0]?.agentId
|
|
54
61
|
chat = {
|
|
55
62
|
...baseChat,
|
|
56
63
|
chatAppId: chatApp._id,
|
|
64
|
+
...(fallbackAgentId && !baseChat.agentId
|
|
65
|
+
? { agentId: fallbackAgentId }
|
|
66
|
+
: {}),
|
|
57
67
|
}
|
|
58
68
|
return chatApp._id
|
|
59
69
|
}
|
|
@@ -81,21 +91,28 @@
|
|
|
81
91
|
const resolvedChatAppId = await ensureChatApp()
|
|
82
92
|
|
|
83
93
|
if (!chat) {
|
|
84
|
-
chat = { title: "", messages: [], chatAppId: "" }
|
|
94
|
+
chat = { title: "", messages: [], chatAppId: "", agentId: "" }
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
const chatAppId = chat.chatAppId || resolvedChatAppId
|
|
98
|
+
const agentId = chat.agentId
|
|
88
99
|
|
|
89
100
|
if (!chatAppId) {
|
|
90
101
|
notifications.error("Chat app could not be created")
|
|
91
102
|
return
|
|
92
103
|
}
|
|
93
104
|
|
|
105
|
+
if (!agentId) {
|
|
106
|
+
notifications.error("Agent is required to start a chat")
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
if (!chat._id && (!chat.messages || chat.messages.length === 0)) {
|
|
95
111
|
try {
|
|
96
112
|
const newChat = await API.createChatConversation(
|
|
97
113
|
{
|
|
98
114
|
chatAppId,
|
|
115
|
+
agentId,
|
|
99
116
|
title: chat.title,
|
|
100
117
|
},
|
|
101
118
|
workspaceId
|
|
@@ -135,7 +152,7 @@
|
|
|
135
152
|
|
|
136
153
|
try {
|
|
137
154
|
const messageStream = await API.streamChatConversation(
|
|
138
|
-
updatedChat,
|
|
155
|
+
updatedChat as ChatConversationRequest,
|
|
139
156
|
workspaceId
|
|
140
157
|
)
|
|
141
158
|
|
|
@@ -366,8 +383,7 @@
|
|
|
366
383
|
display: flex;
|
|
367
384
|
flex-direction: column;
|
|
368
385
|
gap: 24px;
|
|
369
|
-
width:
|
|
370
|
-
margin: 0 auto;
|
|
386
|
+
width: 100%;
|
|
371
387
|
flex: 1 1 auto;
|
|
372
388
|
padding: 48px 0 24px 0;
|
|
373
389
|
}
|
|
@@ -402,8 +418,7 @@
|
|
|
402
418
|
.input-wrapper {
|
|
403
419
|
position: sticky;
|
|
404
420
|
bottom: 0;
|
|
405
|
-
width:
|
|
406
|
-
margin: 0 auto;
|
|
421
|
+
width: 100%;
|
|
407
422
|
background: var(--background-alt);
|
|
408
423
|
padding-bottom: 32px;
|
|
409
424
|
display: flex;
|