Add edit functionality to PlaygroundMessage component

This commit is contained in:
n4ze3m
2024-03-16 00:30:41 +05:30
parent 5b04e55a03
commit 78c44e13b0
6 changed files with 197 additions and 11 deletions

View File

@@ -4,7 +4,13 @@ import { PlaygroundEmpty } from "./PlaygroundEmpty"
import { PlaygroundMessage } from "~components/Common/Playground/Message"
export const PlaygroundChat = () => {
const { messages, streaming, regenerateLastMessage, isSearchingInternet } = useMessageOption()
const {
messages,
streaming,
regenerateLastMessage,
isSearchingInternet,
editMessage
} = useMessageOption()
const divRef = React.useRef<HTMLDivElement>(null)
React.useEffect(() => {
if (divRef.current) {
@@ -32,6 +38,9 @@ export const PlaygroundChat = () => {
isProcessing={streaming}
isSearchingInternet={isSearchingInternet}
sources={message.sources}
onEditFormSubmit={(value) => {
editMessage(index, value, !message.isBot)
}}
/>
))}
{messages.length > 0 && (