feat(HoverButtons.jsx): enable message regeneration for bingAI endpoint (#349)

feat(HoverButtons.jsx): add active class to copy button only if message is not created by user
This commit is contained in:
Danny Avila 2023-05-21 14:01:46 -04:00 committed by GitHub
parent 4beb06aa4b
commit 10de50416b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { cn } from '~/utils/';
import Clipboard from '../svg/Clipboard'; import Clipboard from '../svg/Clipboard';
import CheckMark from '../svg/CheckMark'; import CheckMark from '../svg/CheckMark';
import EditIcon from '../svg/EditIcon'; import EditIcon from '../svg/EditIcon';
@ -13,14 +14,13 @@ export default function HoverButtons({
message, message,
regenerate regenerate
}) { }) {
const { endpoint, jailbreak = false } = conversation; const { endpoint } = conversation;
const [isCopied, setIsCopied] = React.useState(false); const [isCopied, setIsCopied] = React.useState(false);
const branchingSupported = const branchingSupported =
// azureOpenAI, openAI, chatGPTBrowser support branching, so edit enabled // azureOpenAI, openAI, chatGPTBrowser support branching, so edit enabled // 5/21/23: Bing is allowing editing and Message regenerating
!!['azureOpenAI', 'openAI', 'chatGPTBrowser', 'google'].find((e) => e === endpoint) || !!['azureOpenAI', 'openAI', 'chatGPTBrowser', 'google', 'bingAI'].find((e) => e === endpoint);
// Sydney in bingAI supports branching, so edit enabled // Sydney in bingAI supports branching, so edit enabled
(endpoint === 'bingAI' && jailbreak);
const editEnabled = const editEnabled =
!message?.error && !message?.error &&
@ -30,7 +30,7 @@ export default function HoverButtons({
branchingSupported; branchingSupported;
// for now, once branching is supported, regerate will be enabled // for now, once branching is supported, regerate will be enabled
const regenerateEnabled = let regenerateEnabled =
// !message?.error && // !message?.error &&
!message?.isCreatedByUser && !message?.isCreatedByUser &&
!message?.searchResult && !message?.searchResult &&
@ -64,7 +64,10 @@ export default function HoverButtons({
) : null} ) : null}
<button <button
className="hover-button active rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible" className={cn(
'hover-button rounded-md p-1 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible',
message?.isCreatedByUser ? '' : 'active'
)}
onClick={() => copyToClipboard(setIsCopied)} onClick={() => copyToClipboard(setIsCopied)}
type="button" type="button"
title={isCopied ? 'Copied to clipboard' : 'Copy to clipboard'} title={isCopied ? 'Copied to clipboard' : 'Copy to clipboard'}