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

@ -29,13 +29,12 @@ import { sanitizeUIMessages } from '@/lib/utils';
import {
ArrowUpIcon,
CodeIcon,
FileIcon,
LogsIcon,
MessageIcon,
PenIcon,
SparklesIcon,
StopIcon,
SummarizeIcon,
TerminalIcon,
} from './icons';
import { BlockKind } from './block';
@ -327,6 +326,7 @@ const toolsByBlockKind: Record<
icon: <LogsIcon />,
},
],
image: [],
};
export const Tools = ({
@ -347,7 +347,7 @@ export const Tools = ({
) => Promise<string | null | undefined>;
isAnimating: boolean;
setIsToolbarVisible: Dispatch<SetStateAction<boolean>>;
blockKind: 'text' | 'code';
blockKind: BlockKind;
}) => {
const [primaryTool, ...secondaryTools] = toolsByBlockKind[blockKind];
@ -407,7 +407,7 @@ const PureToolbar = ({
) => Promise<string | null | undefined>;
stop: () => void;
setMessages: Dispatch<SetStateAction<Message[]>>;
blockKind: 'text' | 'code';
blockKind: BlockKind;
}) => {
const toolbarRef = useRef<HTMLDivElement>(null);
const timeoutRef = useRef<ReturnType<typeof setTimeout>>();
@ -451,6 +451,10 @@ const PureToolbar = ({
}
}, [isLoading, setIsToolbarVisible]);
if (toolsByBlockKind[blockKind].length === 0) {
return null;
}
return (
<TooltipProvider delayDuration={0}>
<motion.div