Forking
Cascaide allows you to fork a cascade using the useCascade hook. It accepts an optional sourceCascadeId
(which falls back to the cascadeId with which the hook was invoked), a newCascadeId and an upToFunctionId.
Behaviour
- this method will clone the data of the sourceCascade up until but not including the
upToFunctionIdin the durable database. - it will hydrate the local client state with this data.
- you can continue with this new
cascadeIdindependently of the original cascade.
Example
const { forkCascade } = useCascade(cascadeId);
const handleFork = useCallback(async () => {
const newCascadeId = uuidv4(); // branches into a fresh cascade
setForkStatus('loading');
const result = await forkCascade(newCascadeId, forkFunctionId);
setForkStatus(result.status);
// Optional: switch the active chat to the fork
setChatId(newCascadeId);
}, [forkCascade, forkFunctionId]);
Definition
forkCascade(
newCascadeId: string,
upToFunctionId: number,
sourceCascadeId?: string
): Promise<{ status: 'SUCCESS' | 'FAILED' }>
Last updated on