diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoiceView.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoiceView.tsx index e511d6fbf5cd..cca47eae5f86 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoiceView.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoiceView.tsx @@ -21,7 +21,7 @@ export const ChoiceView = ({ const {message} = choice; return (
{choices.map((c, index) => ( -
+
{index === selectedChoiceIndex ? ( diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoicesViewCarousel.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoicesViewCarousel.tsx index b19afb7c3f4f..8befed430096 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoicesViewCarousel.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChoicesViewCarousel.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useEffect} from 'react'; import {Button} from '../../../../../Button'; import {ChoiceView} from './ChoiceView'; @@ -28,11 +28,22 @@ export const ChoicesViewCarousel = ({ setSelectedChoiceIndex(newStep); }; + useEffect(() => { + if (selectedChoiceIndex >= choices.length) { + setSelectedChoiceIndex(choices.length - 1); + } + }, [selectedChoiceIndex, choices, setSelectedChoiceIndex]); + + const choiceIndex = + selectedChoiceIndex >= choices.length + ? choices.length - 1 + : selectedChoiceIndex; + return (
diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/PlaygroundMessagePanelButtons.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/PlaygroundMessagePanelButtons.tsx index 9c286019409d..d4cd3a44c183 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/PlaygroundMessagePanelButtons.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/PlaygroundMessagePanelButtons.tsx @@ -67,12 +67,7 @@ export const PlaygroundMessagePanelButtons: React.FC< size="small" startIcon="pencil-edit" onClick={() => { - setEditorHeight( - contentRef?.current?.clientHeight - ? // Accounts for padding and save buttons - contentRef.current.clientHeight - 56 - : null - ); + setEditorHeight(contentRef?.current?.clientHeight ?? null); }} tooltip={ !hasContent ? 'We currently do not support editing functions' : 'Edit' diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChat.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChat.tsx index 8fc02fea9b10..c3a30d67adf2 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChat.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChat.tsx @@ -155,7 +155,7 @@ export const PlaygroundChat = ({ deleteMessage(idx, messageIndex, responseIndexes), editMessage: (messageIndex, newMessage) => editMessage(idx, messageIndex, newMessage), - deleteChoice: choiceIndex => + deleteChoice: (messageIndex, choiceIndex) => deleteChoice(idx, choiceIndex), addMessage: newMessage => addMessage(idx, newMessage), editChoice: (choiceIndex, newChoice) => diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/useChatCompletionFunctions.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/useChatCompletionFunctions.tsx index 80e4a32d0add..23c30c7e5584 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/useChatCompletionFunctions.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/useChatCompletionFunctions.tsx @@ -218,7 +218,9 @@ const appendChoiceToMessages = ( updatedState.traceCall.inputs.messages.push( updatedState.traceCall.output.choices[choiceIndex].message ); - } else { + } else if ( + updatedState.traceCall.output.choices[updatedState.selectedChoiceIndex] + ) { updatedState.traceCall.inputs.messages.push( updatedState.traceCall.output.choices[updatedState.selectedChoiceIndex] .message diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundPage.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundPage.tsx index 4cadba37db91..7358468ee5cc 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundPage.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundPage.tsx @@ -108,11 +108,9 @@ export const PlaygroundPageInner = (props: PlaygroundPageProps) => { setPlaygroundStateFromTraceCall(callWithCosts.result.traceCall); } } - }, [ - callWithCosts.loading, - setPlaygroundStateFromTraceCall, - callWithCosts.result, - ]); + // Only set the call the first time the page loads, and we get the call + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [callWithCosts.loading]); useEffect(() => { setPlaygroundStates(prev => {