-
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.
Merge branch 'master' into robustness-scorer
- Loading branch information
Showing
16 changed files
with
543 additions
and
73 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
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
79 changes: 79 additions & 0 deletions
79
...ponents/PagePanelComponents/Home/Browse3/pages/ChatView/PlaygroundMessagePanelButtons.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,79 @@ | ||
import {Button} from '@wandb/weave/components/Button'; | ||
import React from 'react'; | ||
|
||
import {usePlaygroundContext} from '../PlaygroundPage/PlaygroundContext'; | ||
|
||
type PlaygroundMessagePanelButtonsProps = { | ||
index: number; | ||
isChoice: boolean; | ||
isTool: boolean; | ||
hasContent: boolean; | ||
contentRef: React.RefObject<HTMLDivElement>; | ||
setEditorHeight: (height: number | null) => void; | ||
responseIndexes?: number[]; | ||
}; | ||
|
||
export const PlaygroundMessagePanelButtons: React.FC< | ||
PlaygroundMessagePanelButtonsProps | ||
> = ({ | ||
index, | ||
isChoice, | ||
isTool, | ||
hasContent, | ||
contentRef, | ||
setEditorHeight, | ||
responseIndexes, | ||
}) => { | ||
const {deleteMessage, deleteChoice, retry} = usePlaygroundContext(); | ||
|
||
return ( | ||
<div className="z-10 flex gap-4 rounded-lg border border-moon-250 bg-white p-4"> | ||
<Button | ||
variant="quiet" | ||
size="small" | ||
startIcon="randomize-reset-reload" | ||
onClick={() => retry?.(index, isChoice)} | ||
tooltip={ | ||
!hasContent | ||
? 'We currently do not support retrying functions' | ||
: 'Retry' | ||
} | ||
disabled={!hasContent}> | ||
Retry | ||
</Button> | ||
<Button | ||
variant="quiet" | ||
size="small" | ||
startIcon="pencil-edit" | ||
onClick={() => { | ||
setEditorHeight( | ||
contentRef?.current?.clientHeight | ||
? // Accounts for padding and save buttons | ||
contentRef.current.clientHeight - 56 | ||
: null | ||
); | ||
}} | ||
tooltip={ | ||
!hasContent ? 'We currently do not support editing functions' : 'Edit' | ||
} | ||
disabled={!hasContent}> | ||
Edit | ||
</Button> | ||
<Button | ||
variant="quiet" | ||
size="small" | ||
startIcon="delete" | ||
onClick={() => { | ||
if (isChoice) { | ||
deleteChoice?.(index); | ||
} else { | ||
deleteMessage?.(index, responseIndexes); | ||
} | ||
}} | ||
tooltip={isTool ? 'Tool responses cannot be deleted' : 'Delete message'} | ||
disabled={isTool}> | ||
Delete | ||
</Button> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.