feat: add image block type (#709)

This commit is contained in:
Jeremy 2025-01-15 19:59:29 +05:30 committed by GitHub
parent 6c23a8a604
commit df449a408a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 229 additions and 92 deletions

View file

@ -6,13 +6,13 @@ import { BlockKind } from './block';
import { Suggestion } from '@/lib/db/schema';
import { initialBlockData, useBlock } from '@/hooks/use-block';
import { useUserMessageId } from '@/hooks/use-user-message-id';
import { cx } from 'class-variance-authority';
import { useSWRConfig } from 'swr';
type DataStreamDelta = {
type:
| 'text-delta'
| 'code-delta'
| 'image-delta'
| 'title'
| 'id'
| 'suggestion'
@ -107,6 +107,14 @@ export function DataStreamHandler({ id }: { id: string }) {
status: 'streaming',
};
case 'image-delta':
return {
...draftBlock,
content: delta.content as string,
isVisible: true,
status: 'streaming',
};
case 'suggestion':
setTimeout(() => {
setOptimisticSuggestions((currentSuggestions) => [