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 ec6653801978..270f030a1b61 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 @@ -10,6 +10,7 @@ import {PlaygroundState} from '../types'; import {PlaygroundCallStats} from './PlaygroundCallStats'; import {PlaygroundChatInput} from './PlaygroundChatInput'; import {PlaygroundChatTopBar} from './PlaygroundChatTopBar'; +import {useChatCompletionFunctions} from './useChatCompletionFunctions'; import { SetPlaygroundStateFieldFunctionType, useChatFunctions, @@ -35,10 +36,19 @@ export const PlaygroundChat = ({ settingsTab, }: PlaygroundChatProps) => { const [chatText, setChatText] = useState(''); - // eslint-disable-next-line @typescript-eslint/no-unused-vars const [isLoading, setIsLoading] = useState(false); const chatPercentWidth = 100 / playgroundStates.length; + const {handleRetry, handleSend} = useChatCompletionFunctions( + setPlaygroundStates, + setIsLoading, + chatText, + playgroundStates, + entity, + project, + setChatText + ); + const {deleteMessage, editMessage, deleteChoice, editChoice, addMessage} = useChatFunctions(setPlaygroundStateField); @@ -145,18 +155,14 @@ export const PlaygroundChat = ({ editChoice: (choiceIndex, newChoice) => editChoice(idx, choiceIndex, newChoice), retry: (messageIndex: number, isChoice?: boolean) => - console.log('retry', messageIndex, isChoice), + handleRetry(idx, messageIndex, isChoice), sendMessage: ( role: 'assistant' | 'user' | 'tool', content: string, toolCallId?: string - ) => - console.log( - 'sendMessage', - role, - content, - toolCallId - ), + ) => { + handleSend(role, idx, content, toolCallId); + }, }}> @@ -187,7 +193,7 @@ export const PlaygroundChat = ({ chatText={chatText} setChatText={setChatText} isLoading={isLoading} - onSend={() => {}} + onSend={handleSend} onAdd={handleAddMessage} /> diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChatTopBar.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChatTopBar.tsx index 2fcd24f56e3a..7e1b4b13bb13 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChatTopBar.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChatTopBar.tsx @@ -79,7 +79,7 @@ export const PlaygroundChatTopBar: React.FC = ({ display: 'flex', gap: '8px', alignItems: 'center', - backgroundColor: 'white', + backgroundColor: 'transparent', }}> {!onlyOneChat && } = ({ display: 'flex', alignItems: 'center', gap: '4px', - backgroundColor: 'white', + backgroundColor: 'transparent', }}>