Skip to content

Commit

Permalink
⚡ (engine) Implement skip on engine v2
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 27, 2023
1 parent f93bc2f commit d54822a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion apps/viewer/src/features/chat/api/utils/continueBotFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export const continueBotFlow =

const formattedReply = formatReply(reply, block.type)

if (!formattedReply || !isReplyValid(formattedReply, block))
if (
!formattedReply ||
!isReplyValid(formattedReply, block) ||
(!formatReply && !canSkip(block.type))
)
return parseRetryMessage(block)

const newVariables = await processAndSaveAnswer(
Expand Down Expand Up @@ -229,3 +233,6 @@ export const isReplyValid = (inputValue: string, block: Block): boolean => {
}
return true
}

export const canSkip = (inputType: InputBlockType) =>
inputType === InputBlockType.FILE
Original file line number Diff line number Diff line change
Expand Up @@ -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
if (currentBlockId && props.onAnswer)
if (currentBlockId && props.onAnswer && message)
props.onAnswer({ message, blockId: currentBlockId })
const longRequest = setTimeout(() => {
setIsSending(true)
Expand Down Expand Up @@ -133,6 +133,8 @@ export const ConversationContainer = (props: Props) => {
}
}

const handleSkip = () => sendMessage(undefined)

return (
<div
ref={chatContainer}
Expand All @@ -151,9 +153,7 @@ export const ConversationContainer = (props: Props) => {
onAllBubblesDisplayed={handleAllBubblesDisplayed}
onSubmit={sendMessage}
onScrollToBottom={autoScrollToBottom}
onSkip={() => {
// TODO: implement skip
}}
onSkip={handleSkip}
context={props.context}
/>
)}
Expand Down

0 comments on commit d54822a

Please sign in to comment.