⚡ (engine) Implement skip on engine v2
This commit is contained in:
@@ -52,7 +52,11 @@ export const continueBotFlow =
|
|||||||
|
|
||||||
const formattedReply = formatReply(reply, block.type)
|
const formattedReply = formatReply(reply, block.type)
|
||||||
|
|
||||||
if (!formattedReply || !isReplyValid(formattedReply, block))
|
if (
|
||||||
|
!formattedReply ||
|
||||||
|
!isReplyValid(formattedReply, block) ||
|
||||||
|
(!formatReply && !canSkip(block.type))
|
||||||
|
)
|
||||||
return parseRetryMessage(block)
|
return parseRetryMessage(block)
|
||||||
|
|
||||||
const newVariables = await processAndSaveAnswer(
|
const newVariables = await processAndSaveAnswer(
|
||||||
@@ -229,3 +233,6 @@ export const isReplyValid = (inputValue: string, block: Block): boolean => {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const canSkip = (inputType: InputBlockType) =>
|
||||||
|
inputType === InputBlockType.FILE
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ export const ConversationContainer = (props: Props) => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const sendMessage = async (message: string) => {
|
const sendMessage = async (message: string | undefined) => {
|
||||||
const currentBlockId = chatChunks().at(-1)?.input?.id
|
const currentBlockId = chatChunks().at(-1)?.input?.id
|
||||||
if (currentBlockId && props.onAnswer)
|
if (currentBlockId && props.onAnswer && message)
|
||||||
props.onAnswer({ message, blockId: currentBlockId })
|
props.onAnswer({ message, blockId: currentBlockId })
|
||||||
const longRequest = setTimeout(() => {
|
const longRequest = setTimeout(() => {
|
||||||
setIsSending(true)
|
setIsSending(true)
|
||||||
@@ -133,6 +133,8 @@ export const ConversationContainer = (props: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleSkip = () => sendMessage(undefined)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={chatContainer}
|
ref={chatContainer}
|
||||||
@@ -151,9 +153,7 @@ export const ConversationContainer = (props: Props) => {
|
|||||||
onAllBubblesDisplayed={handleAllBubblesDisplayed}
|
onAllBubblesDisplayed={handleAllBubblesDisplayed}
|
||||||
onSubmit={sendMessage}
|
onSubmit={sendMessage}
|
||||||
onScrollToBottom={autoScrollToBottom}
|
onScrollToBottom={autoScrollToBottom}
|
||||||
onSkip={() => {
|
onSkip={handleSkip}
|
||||||
// TODO: implement skip
|
|
||||||
}}
|
|
||||||
context={props.context}
|
context={props.context}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user