🚸 Display error toast when script or set vari…

This commit is contained in:
Baptiste Arnaud
2024-06-11 18:18:05 +02:00
parent d80b3eaddb
commit 233ff91a57
15 changed files with 151 additions and 50 deletions

View File

@@ -131,18 +131,18 @@ export const ConversationContainer = (props: Props) => {
)
})
const sendMessage = async (
message: string | undefined,
clientLogs?: ChatLog[]
) => {
if (clientLogs) {
props.onNewLogs?.(clientLogs)
await saveClientLogsQuery({
apiHost: props.context.apiHost,
sessionId: props.initialChatReply.sessionId,
clientLogs,
})
}
const saveLogs = async (clientLogs?: ChatLog[]) => {
if (!clientLogs) return
props.onNewLogs?.(clientLogs)
if (props.context.isPreview) return
await saveClientLogsQuery({
apiHost: props.context.apiHost,
sessionId: props.initialChatReply.sessionId,
clientLogs,
})
}
const sendMessage = async (message: string | undefined) => {
setHasError(false)
const currentInputBlock = [...chatChunks()].pop()?.input
if (currentInputBlock?.id && props.onAnswer && message)
@@ -288,9 +288,10 @@ export const ConversationContainer = (props: Props) => {
},
onMessageStream: streamMessage,
})
if (response && 'logs' in response) saveLogs(response.logs)
if (response && 'replyToSend' in response) {
setIsSending(false)
sendMessage(response.replyToSend, response.logs)
sendMessage(response.replyToSend)
return
}
if (response && 'blockedPopupUrl' in response)