refactor(useGenerationsByLatest): make agents and bedrock editable

This commit is contained in:
Danny Avila 2024-09-02 20:51:20 -04:00
parent 9cda192c1b
commit 2c2dd57af5
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364

View file

@ -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;