From 2c2dd57af5e0ecc8cc7e568f62f19707ec6c9cdd Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 2 Sep 2024 20:51:20 -0400 Subject: [PATCH] refactor(useGenerationsByLatest): make agents and bedrock editable --- client/src/hooks/useGenerationsByLatest.ts | 40 ++++++++++++++-------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/client/src/hooks/useGenerationsByLatest.ts b/client/src/hooks/useGenerationsByLatest.ts index 8dc37062f2..47bb935129 100644 --- a/client/src/hooks/useGenerationsByLatest.ts +++ b/client/src/hooks/useGenerationsByLatest.ts @@ -3,7 +3,7 @@ import { EModelEndpoint, isAssistantsEndpoint } from 'librechat-data-provider'; type TUseGenerations = { endpoint?: string; - message: TMessage; + message?: TMessage; isSubmitting: boolean; isEditing?: boolean; latestMessage: TMessage | null; @@ -16,15 +16,25 @@ export default function useGenerationsByLatest({ isEditing = false, latestMessage, }: TUseGenerations) { - const { error, messageId, searchResult, finish_reason, isCreatedByUser } = message ?? {}; - const isEditableEndpoint = !![ - EModelEndpoint.openAI, - EModelEndpoint.custom, - EModelEndpoint.google, - EModelEndpoint.anthropic, - EModelEndpoint.gptPlugins, - EModelEndpoint.azureOpenAI, - ].find((e) => e === endpoint); + const { + messageId, + searchResult = false, + error = false, + finish_reason = '', + isCreatedByUser = false, + } = message ?? {}; + const isEditableEndpoint = Boolean( + [ + EModelEndpoint.openAI, + EModelEndpoint.custom, + EModelEndpoint.google, + EModelEndpoint.agents, + EModelEndpoint.bedrock, + EModelEndpoint.anthropic, + EModelEndpoint.gptPlugins, + EModelEndpoint.azureOpenAI, + ].find((e) => e === endpoint), + ); const continueSupported = latestMessage?.messageId === messageId && @@ -34,18 +44,20 @@ export default function useGenerationsByLatest({ !searchResult && isEditableEndpoint; - const branchingSupported = - // 5/21/23: Bing is allowing editing and Message regenerating - !![ + const branchingSupported = Boolean( + [ EModelEndpoint.azureOpenAI, EModelEndpoint.openAI, EModelEndpoint.custom, + EModelEndpoint.agents, + EModelEndpoint.bedrock, EModelEndpoint.chatGPTBrowser, EModelEndpoint.google, EModelEndpoint.bingAI, EModelEndpoint.gptPlugins, EModelEndpoint.anthropic, - ].find((e) => e === endpoint); + ].find((e) => e === endpoint), + ); const regenerateEnabled = !isCreatedByUser && !searchResult && !isEditing && !isSubmitting && branchingSupported;