Stream bubble content if placed right after Op…

Closes #617
This commit is contained in:
Baptiste Arnaud
2023-07-19 11:20:44 +02:00
parent 6c540657a6
commit 3952ae2755
14 changed files with 231 additions and 34 deletions

View File

@@ -11,11 +11,17 @@ import { ClientSideActionContext } from '@/types'
import type { ChatReply, ReplyLog } from '@typebot.io/schemas'
import { injectStartProps } from './injectStartProps'
export const executeClientSideAction = async (
clientSideAction: NonNullable<ChatReply['clientSideActions']>[0],
context: ClientSideActionContext,
onStreamedMessage?: (message: string) => void
): Promise<
type Props = {
clientSideAction: NonNullable<ChatReply['clientSideActions']>[0]
context: ClientSideActionContext
onMessageStream?: (message: string) => void
}
export const executeClientSideAction = async ({
clientSideAction,
context,
onMessageStream,
}: Props): Promise<
| { blockedPopupUrl: string }
| { replyToSend: string | undefined; logs?: ReplyLog[] }
| void
@@ -41,7 +47,12 @@ export const executeClientSideAction = async (
if ('streamOpenAiChatCompletion' in clientSideAction) {
const { error, message } = await streamChat(context)(
clientSideAction.streamOpenAiChatCompletion.messages,
{ onStreamedMessage }
{
onMessageStream: clientSideAction.streamOpenAiChatCompletion
.displayStream
? onMessageStream
: undefined,
}
)
if (error)
return {