diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx index 9a028ab..94eea31 100644 --- a/src/components/chat/ChatInput.tsx +++ b/src/components/chat/ChatInput.tsx @@ -46,6 +46,10 @@ export function ChatInput(): React.JSX.Element { const isStreaming = useAgentStore((s) => s.isStreaming); const tokenUsage = useAgentStore((s) => s.tokenUsage); const currentSessionId = useSessionStore((s) => s.currentSessionId); + const provider = useAgentStore((s) => s.provider); + + /** DeepSeek 不支持多模态图片 */ + const supportsImages = provider !== 'deepseek'; // 草稿自动保存 useEffect(() => { if (currentSessionId) { const d = sessionStorage.getItem(`draft-${currentSessionId}`); setInput(d ?? ''); } }, [currentSessionId]); @@ -85,9 +89,21 @@ export function ChatInput(): React.JSX.Element { const addFiles = useCallback(async (files: FileList | File[]) => { const fileArray = Array.from(files).slice(0, 5); // 最多 5 个附件 - const newAttachments = await Promise.all(fileArray.map(processFile)); + + // DeepSeek 不支持多模态,过滤图片 + const filtered = supportsImages + ? fileArray + : fileArray.filter((f) => !IMAGE_TYPES.includes(f.type)); + + if (filtered.length < fileArray.length && !supportsImages) { + // TODO: 用 Toast 提示用户 "DeepSeek 不支持图片,已自动跳过 N 个图片文件" + } + + if (filtered.length === 0) return; + + const newAttachments = await Promise.all(filtered.map(processFile)); setAttachments((prev) => [...prev, ...newAttachments]); - }, [processFile]); + }, [processFile, supportsImages]); const removeAttachment = useCallback((id: string) => { setAttachments((prev) => prev.filter((a) => a.id !== id)); @@ -224,7 +240,7 @@ export function ChatInput(): React.JSX.Element { )} - +