-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
2,861 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/CallChat.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Get normalized version of call data in chat format and display it. | ||
*/ | ||
|
||
import React, {useEffect, useState} from 'react'; | ||
|
||
import {LoadingDots} from '../../../../../LoadingDots'; | ||
import {PlaygroundContext} from '../PlaygroundPage/PlaygroundChat/PlaygroundContext'; | ||
import {TraceCallSchema} from '../wfReactInterface/traceServerClientTypes'; | ||
import {ChatView} from './ChatView'; | ||
import {useCallAsChat} from './hooks'; | ||
|
||
type CallChatProps = { | ||
call: TraceCallSchema; | ||
isPlayground?: boolean; | ||
deleteMessage?: (messageIndex: number) => void; | ||
editMessage?: (messageIndex: number, newMessage: any) => void; | ||
deleteChoice?: (choiceIndex: number) => void; | ||
addMessage?: (newMessage: any) => void; | ||
editChoice?: (choiceIndex: number, newChoice: any) => void; | ||
retry?: (messageIndex: number, isChoice?: boolean) => void; | ||
}; | ||
|
||
export const CallChat = ({ | ||
call, | ||
isPlayground = false, | ||
deleteMessage, | ||
editMessage, | ||
deleteChoice, | ||
addMessage, | ||
editChoice, | ||
retry, | ||
}: CallChatProps) => { | ||
const chat = useCallAsChat(call); | ||
|
||
// This is used because when we first load the chat view in a drawer, the animation cant handle all the rows | ||
// so we delay for the first render | ||
const [animationBuffer, setAnimationBuffer] = useState(true); | ||
useEffect(() => { | ||
setTimeout(() => { | ||
setAnimationBuffer(false); | ||
}, 300); | ||
}, []); | ||
|
||
if (chat.loading || animationBuffer) { | ||
return <LoadingDots />; | ||
} | ||
return ( | ||
<PlaygroundContext.Provider | ||
value={{ | ||
isPlayground, | ||
deleteMessage, | ||
editMessage, | ||
deleteChoice, | ||
addMessage, | ||
editChoice, | ||
retry, | ||
}}> | ||
<ChatView call={call} chat={chat} /> | ||
</PlaygroundContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 57 additions & 6 deletions
63
weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/MessageList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.