diff --git a/package.json b/package.json index df967fb..2944cb5 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@tanstack/react-query": "^5.17.19", + "@types/pdf-parse": "^1.1.4", "antd": "^5.13.3", "axios": "^1.6.7", "dayjs": "^1.11.10", diff --git a/src/components/Common/Markdown.tsx b/src/components/Common/Markdown.tsx index 5c33124..2a0cac5 100644 --- a/src/components/Common/Markdown.tsx +++ b/src/components/Common/Markdown.tsx @@ -24,7 +24,7 @@ export default function Markdown({ message }: { message: string }) { return ( void + isProcessing: boolean + webSearch?: { + + } } export const PlaygroundMessage = (props: Props) => { const [isBtnPressed, setIsBtnPressed] = React.useState(false) - React.useEffect(() => { - if (isBtnPressed) { - setTimeout(() => { - setIsBtnPressed(false) - }, 4000) - } - }, [isBtnPressed]) - return ( -
+
@@ -45,52 +44,61 @@ export const PlaygroundMessage = (props: Props) => { )}
-
- {props.isBot && ( - - {props.name} - - )} -
+
+ + {props.isBot ? props.name : "You"} + + +
{/* source if aviable */} - {props.images && ( + {props.images && props.images.length > 0 && (
- {props.images && ( -
- {props.images - .filter((image) => image.length > 0) - .map((image, index) => ( - Uploaded Image - ))} -
- )} + {props.images + .filter((image) => image.length > 0) + .map((image, index) => ( + Uploaded Image + ))}
)} - - {props.isBot && ( -
+ {props.isBot && !props.isProcessing && ( +
{!props.hideCopy && ( - + + + )} + + {/* {props.currentMessageIndex === props.totalMessages - 1 && ( + + + + )} */}
)}
diff --git a/src/components/Common/SaveButton.tsx b/src/components/Common/SaveButton.tsx index 0aba6d4..0767aa6 100644 --- a/src/components/Common/SaveButton.tsx +++ b/src/components/Common/SaveButton.tsx @@ -1,11 +1,12 @@ import { useState } from "react" type Props = { - onClick: () => void + onClick?: () => void disabled?: boolean className?: string text?: string textOnSave?: string + btnType?: "button" | "submit" | "reset" } export const SaveButton = ({ @@ -13,11 +14,13 @@ export const SaveButton = ({ disabled, className, text = "Save", - textOnSave = "Saved" + textOnSave = "Saved", + btnType = "button" }: Props) => { const [clickedSave, setClickedSave] = useState(false) return (
)} - {messages.length > 0 &&
} + {messages.length > 0 &&
} {messages.map((message, index) => ( { message={message.message} name={message.name} images={message.images || []} + currentMessageIndex={index} + totalMessages={messages.length} + onRengerate={regenerateLastMessage} + isProcessing={streaming} /> ))} {messages.length > 0 && ( diff --git a/src/components/Option/Playground/PlaygroundForm.tsx b/src/components/Option/Playground/PlaygroundForm.tsx index 9d62001..9ae6558 100644 --- a/src/components/Option/Playground/PlaygroundForm.tsx +++ b/src/components/Option/Playground/PlaygroundForm.tsx @@ -4,13 +4,14 @@ import React from "react" import useDynamicTextareaSize from "~hooks/useDynamicTextareaSize" import { toBase64 } from "~libs/to-base64" import { useMessageOption } from "~hooks/useMessageOption" -import { Tooltip } from "antd" +import { Checkbox, Dropdown, Tooltip } from "antd" import { Image } from "antd" import { useSpeechRecognition } from "~hooks/useSpeechRecognition" import { MicIcon } from "~icons/MicIcon" import { StopCircleIcon } from "~icons/StopCircleIcon" import { PhotoIcon } from "~icons/PhotoIcon" import { XMarkIcon } from "~icons/XMarkIcon" +import { useWebUI } from "~store/webui" type Props = { dropedFile: File | undefined @@ -66,10 +67,12 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { selectedModel, chatMode, speechToTextLanguage, - stopStreamingRequest + stopStreamingRequest, + streaming: isSending } = useMessageOption() const { isListening, start, stop, transcript } = useSpeechRecognition() + const { sendWhenEnter, setSendWhenEnter } = useWebUI() React.useEffect(() => { if (isListening) { @@ -79,7 +82,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { const queryClient = useQueryClient() - const { mutateAsync: sendMessage, isPending: isSending } = useMutation({ + const { mutateAsync: sendMessage } = useMutation({ mutationFn: onSubmit, onSuccess: () => { queryClient.invalidateQueries({ @@ -149,7 +152,12 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {