import Markdown from "../../Common/Markdown" import React from "react" import { Tag, Image, Tooltip } from "antd" import { WebSearch } from "./WebSearch" import { CheckIcon, ClipboardIcon, Pen, PlayIcon, RotateCcw, Square } from "lucide-react" import { EditMessageForm } from "./EditMessageForm" import { useTranslation } from "react-i18next" import { MessageSource } from "./MessageSource" import { useTTS } from "@/hooks/useTTS" import { tagColors } from "@/utils/color" type Props = { message: string message_type?: string hideCopy?: boolean botAvatar?: JSX.Element userAvatar?: JSX.Element isBot: boolean name: string images?: string[] currentMessageIndex: number totalMessages: number onRengerate: () => void onEditFormSubmit: (value: string) => void isProcessing: boolean webSearch?: {} isSearchingInternet?: boolean sources?: any[] hideEditAndRegenerate?: boolean onSourceClick?: (source: any) => void isTTSEnabled?: boolean } export const PlaygroundMessage = (props: Props) => { const [isBtnPressed, setIsBtnPressed] = React.useState(false) const [editMode, setEditMode] = React.useState(false) const { t } = useTranslation("common") const { cancel, isSpeaking, speak } = useTTS() return (
{props.isBot ? ( !props.botAvatar ? (
) : ( props.botAvatar ) ) : !props.userAvatar ? (
) : ( props.userAvatar )}
{props.isBot ? props.name === "chrome::gemini-nano::page-assist" ? "Gemini Nano" : props.name : "You"} {props.isBot && props.isSearchingInternet && props.currentMessageIndex === props.totalMessages - 1 ? ( ) : null}
{props?.message_type && ( {t(`copilot.${props?.message_type}`)} )}
{!editMode ? ( props.isBot ? ( ) : (

{props.message}

) ) : ( setEditMode(false)} isBot={props.isBot} /> )}
{/* source if aviable */} {props.images && props.images && props.images.filter((img) => img.length > 0).length > 0 && (
{props.images .filter((image) => image.length > 0) .map((image, index) => ( Uploaded Image ))}
)} {props.isBot && props?.sources && props?.sources.length > 0 && (
{props?.sources?.map((source, index) => ( ))}
)} {!props.isProcessing && !editMode && (
{props.isTTSEnabled && ( )} {props.isBot && ( <> {!props.hideCopy && ( )} {!props.hideEditAndRegenerate && props.currentMessageIndex === props.totalMessages - 1 && ( )} )} {!props.hideEditAndRegenerate && ( )}
)}
) }