fix(engine): 🐛 Chat chunk management

This commit is contained in:
Baptiste Arnaud
2022-03-03 10:15:20 +01:00
parent 831150e040
commit 4714e8046a
5 changed files with 143 additions and 68 deletions

View File

@@ -1,4 +1,12 @@
import { TypingEmulation } from 'models'
import {
BubbleStep,
BubbleStepType,
InputStep,
InputStepType,
Step,
TypingEmulation,
} from 'models'
import { isBubbleStep, isInputStep } from 'utils'
export const computeTypingTimeout = (
bubbleContent: string,
@@ -14,3 +22,12 @@ export const computeTypingTimeout = (
typingTimeout = typingSettings.maxDelay * 1000
return typingTimeout
}
export const getLastChatStepType = (
steps: Step[]
): BubbleStepType | InputStepType | undefined => {
const displayedSteps = steps.filter(
(s) => isBubbleStep(s) || isInputStep(s)
) as (BubbleStep | InputStep)[]
return displayedSteps.pop()?.type
}