import React from "react"; import { ChatInput } from "./chat-input"; import { cn } from "#/utils/utils"; import { ImageCarousel } from "../images/image-carousel"; import { UploadImageInput } from "../images/upload-image-input"; interface InteractiveChatBoxProps { isDisabled?: boolean; mode?: "stop" | "submit"; onSubmit: (message: string, images: File[]) => void; onStop: () => void; value?: string; onChange?: (message: string) => void; } export function InteractiveChatBox({ isDisabled, mode = "submit", onSubmit, onStop, value, onChange, }: InteractiveChatBoxProps) { const [images, setImages] = React.useState([]); const handleUpload = (files: File[]) => { setImages((prevImages) => [...prevImages, ...files]); }; const handleRemoveImage = (index: number) => { setImages((prevImages) => { const newImages = [...prevImages]; newImages.splice(index, 1); return newImages; }); }; const handleSubmit = (message: string) => { onSubmit(message, images); setImages([]); if (message) { onChange?.(""); } }; return (
{images.length > 0 && ( URL.createObjectURL(image))} onRemove={handleRemoveImage} /> )}
); }