import React from "react" import { useMessageOption } from "~/hooks/useMessageOption" import { PlaygroundEmpty } from "./PlaygroundEmpty" import { PlaygroundMessage } from "~/components/Common/Playground/Message" import { MessageSourcePopup } from "@/components/Common/Playground/MessageSourcePopup" export const PlaygroundChat = () => { const { messages, streaming, regenerateLastMessage, isSearchingInternet, editMessage } = useMessageOption() const divRef = React.useRef(null) const [isSourceOpen, setIsSourceOpen] = React.useState(false) const [source, setSource] = React.useState(null) React.useEffect(() => { if (divRef.current) { divRef.current.scrollIntoView({ behavior: "smooth" }) } }) return ( <> {" "}
{messages.length === 0 && (
)} {/* {messages.length > 0 &&
} */} {messages.map((message, index) => ( { editMessage(index, value, !message.isBot) }} onSourceClick={(data) => { setSource(data) setIsSourceOpen(true) }} /> ))} {messages.length > 0 && (
)}
) }