diff --git a/src/interface/web/app/components/chatMessage/chatMessage.tsx b/src/interface/web/app/components/chatMessage/chatMessage.tsx index d05d9829..ec1e4062 100644 --- a/src/interface/web/app/components/chatMessage/chatMessage.tsx +++ b/src/interface/web/app/components/chatMessage/chatMessage.tsx @@ -30,6 +30,7 @@ import { Code, Shapes, Trash, + ArrowClockwise, } from "@phosphor-icons/react"; import DOMPurify from "dompurify"; @@ -682,6 +683,32 @@ const ChatMessage = forwardRef((props, ref) => } }; + const regenerateMessage = async (message: SingleChatMessage) => { + const turnId = message.turnId || props.turnId; + if (!message.rawQuery) return; + + const response = await fetch("/api/chat", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + q: message.rawQuery, + conversation_id: props.conversationId, + turn_id: turnId, + stream: false, + }), + }); + + if (response.ok) { + const result = await response.json(); + // Update the UI after successful regeneration + props.onDeleteMessage(turnId); + } else { + console.error("Failed to regenerate message"); + } + }; + const allReferences = constructAllReferences( props.chatMessage.context, props.chatMessage.onlineContext, @@ -744,7 +771,7 @@ const ChatMessage = forwardRef((props, ref) => /> ))} - {props.chatMessage.turnId && ( + {props.chatMessage.by === "you" && props.chatMessage.turnId && ( )} + {props.chatMessage.by === "khoj" && props.chatMessage.turnId && ( + + )}