mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00

* chore: remove all bing code * chore: remove bing code and auto-focus effects * chore: add back escapeRegExp helper function for regex special character handling * chore: remove deprecated fields from settings and conversation schema * fix: ensure default endpoint is set correctly in conversation setup * feat: add disableFocus option to newConversation for improved search behavior
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import { EModelEndpoint, isAssistantsEndpoint } from 'librechat-data-provider';
|
|
|
|
type TUseGenerations = {
|
|
error?: boolean;
|
|
endpoint?: string;
|
|
messageId?: string;
|
|
isEditing?: boolean;
|
|
isSubmitting: boolean;
|
|
searchResult?: boolean;
|
|
finish_reason?: string;
|
|
latestMessageId?: string;
|
|
isCreatedByUser?: boolean;
|
|
};
|
|
|
|
export default function useGenerationsByLatest({
|
|
error = false,
|
|
endpoint,
|
|
messageId,
|
|
isEditing = false,
|
|
isSubmitting,
|
|
searchResult = false,
|
|
finish_reason = '',
|
|
latestMessageId,
|
|
isCreatedByUser = false,
|
|
}: TUseGenerations) {
|
|
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 =
|
|
latestMessageId === messageId &&
|
|
finish_reason &&
|
|
finish_reason !== 'stop' &&
|
|
!isEditing &&
|
|
!searchResult &&
|
|
isEditableEndpoint;
|
|
|
|
const branchingSupported = Boolean(
|
|
[
|
|
EModelEndpoint.azureOpenAI,
|
|
EModelEndpoint.openAI,
|
|
EModelEndpoint.custom,
|
|
EModelEndpoint.agents,
|
|
EModelEndpoint.bedrock,
|
|
EModelEndpoint.chatGPTBrowser,
|
|
EModelEndpoint.google,
|
|
EModelEndpoint.gptPlugins,
|
|
EModelEndpoint.anthropic,
|
|
].find((e) => e === endpoint),
|
|
);
|
|
|
|
const regenerateEnabled =
|
|
!isCreatedByUser && !searchResult && !isEditing && !isSubmitting && branchingSupported;
|
|
|
|
const hideEditButton =
|
|
isSubmitting ||
|
|
error ||
|
|
searchResult ||
|
|
!branchingSupported ||
|
|
(!isEditableEndpoint && !isCreatedByUser);
|
|
|
|
const forkingSupported = !isAssistantsEndpoint(endpoint) && !searchResult;
|
|
|
|
return {
|
|
forkingSupported,
|
|
continueSupported,
|
|
regenerateEnabled,
|
|
isEditableEndpoint,
|
|
hideEditButton,
|
|
};
|
|
}
|