diff --git a/frontend/src/Controls.tsx b/frontend/src/Controls.tsx index ac23f28..adc7726 100644 --- a/frontend/src/Controls.tsx +++ b/frontend/src/Controls.tsx @@ -159,6 +159,7 @@ const Controls = ({ sessionId, setSnack, connectionBase }: ControlsParams) => { sendMessageHistoryLength(messageHistoryLength); }, [messageHistoryLength, setMessageHistoryLength, connectionBase, sessionId, setSnack]); + const reset = async (types: ("rags" | "tools" | "history" | "system_prompt" | "message_history_length")[], message: string = "Update successful.") => { try { const response = await fetch(connectionBase + `/api/reset/${sessionId}`, { @@ -406,6 +407,7 @@ const Controls = ({ sessionId, setSnack, connectionBase }: ControlsParams) => { + }> Tunables @@ -429,6 +431,7 @@ const Controls = ({ sessionId, setSnack, connectionBase }: ControlsParams) => { /> + }> Tools @@ -449,6 +452,7 @@ const Controls = ({ sessionId, setSnack, connectionBase }: ControlsParams) => { } + }> RAG @@ -457,12 +461,15 @@ const Controls = ({ sessionId, setSnack, connectionBase }: ControlsParams) => { These RAG databases can be enabled / disabled for adding additional context based on the chat request. - + { rags.map((rag, index) => - + - } onChange={() => toggle("rag", index)} label={rag?.name} /> + } + onChange={() => toggle("rag", index)} label={rag?.name} + /> {rag?.description} ) diff --git a/frontend/src/CopyBubble.tsx b/frontend/src/CopyBubble.tsx new file mode 100644 index 0000000..d08ef66 --- /dev/null +++ b/frontend/src/CopyBubble.tsx @@ -0,0 +1,56 @@ +import { useState } from 'react'; +import ContentCopyIcon from '@mui/icons-material/ContentCopy'; +import CheckIcon from '@mui/icons-material/Check'; +import IconButton from '@mui/material/IconButton'; +import { Tooltip } from '@mui/material'; +import { SxProps, Theme } from '@mui/material'; + +interface CopyBubbleProps { + content: string | undefined, + sx?: SxProps; +} + +const CopyBubble = ({ + content, + sx, +} : CopyBubbleProps) => { + const [copied, setCopied] = useState(false); + + const handleCopy = () => { + if (content === undefined) { + return; + } + + navigator.clipboard.writeText(content.trim()).then(() => { + setCopied(true); + setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds + }); + }; + +return ( + + + {copied ? : } + + + ); +} + +export { + CopyBubble +} \ No newline at end of file diff --git a/frontend/src/Message.tsx b/frontend/src/Message.tsx index 17e2972..92cd8c8 100644 --- a/frontend/src/Message.tsx +++ b/frontend/src/Message.tsx @@ -12,22 +12,19 @@ import TableHead from '@mui/material/TableHead'; import TableRow from '@mui/material/TableRow'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; -import IconButton from '@mui/material/IconButton'; import CardContent from '@mui/material/CardContent'; import CardActions from '@mui/material/CardActions'; import Collapse from '@mui/material/Collapse'; import Typography from '@mui/material/Typography'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import { ExpandMore } from './ExpandMore'; -import ContentCopyIcon from '@mui/icons-material/ContentCopy'; -import CheckIcon from '@mui/icons-material/Check'; import { ChatBubble } from './ChatBubble'; import { StyledMarkdown } from './StyledMarkdown'; -import { Tooltip } from '@mui/material'; import { VectorVisualizer } from './VectorVisualizer'; import { SetSnackType } from './Snack'; +import { CopyBubble } from './CopyBubble'; type MessageRoles = 'info' | 'user' | 'assistant' | 'system' | 'status' | 'error' | 'content'; @@ -127,7 +124,7 @@ const MessageMeta = ({ ...props }: MessageMetaProps) => { -
{props.full_query}
+
{props.full_query.trim()}
} @@ -221,20 +218,8 @@ const ChatQuery = ({ text, submitQuery }: ChatQueryInterface) => { const Message = ({ message, submitQuery, isFullWidth, sessionId, setSnack, connectionBase }: MessageProps) => { const [expanded, setExpanded] = useState(false); - const [copied, setCopied] = useState(false); const textFieldRef = useRef(null); - const handleCopy = () => { - if (message === undefined || message.content === undefined) { - return; - } - - navigator.clipboard.writeText(message.content.trim()).then(() => { - setCopied(true); - setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds - }); - }; - const handleExpandClick = () => { setExpanded(!expanded); }; @@ -266,25 +251,7 @@ const Message = ({ message, submitQuery, isFullWidth, sessionId, setSnack, conne overflowX: "auto" }}> - - - {copied ? : } - - + {message.role !== 'user' ?