diff --git a/client/src/common/types.ts b/client/src/common/types.ts index 7042e079401..f952cd28328 100644 --- a/client/src/common/types.ts +++ b/client/src/common/types.ts @@ -307,6 +307,12 @@ export type TMessageProps = { setSiblingIdx?: ((value: number) => void | React.Dispatch>) | null; }; +export type TMessageIcon = { endpoint?: string | null; isCreatedByUser?: boolean } & Pick< + t.TConversation, + 'modelLabel' +> & + Pick; + export type TInitialProps = { text: string; edit: boolean; diff --git a/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx b/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx index a0a9ef220f9..04bac0bdebe 100644 --- a/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx +++ b/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx @@ -1,3 +1,4 @@ +import { memo } from 'react'; import { EModelEndpoint, KnownEndpoints } from 'librechat-data-provider'; import { CustomMinimalIcon } from '~/components/svg'; import { IconContext } from '~/common'; @@ -53,7 +54,7 @@ const getKnownClass = ({ return cn(match, defaultClass); }; -export default function UnknownIcon({ +function UnknownIcon({ className = '', endpoint: _endpoint, iconURL = '', @@ -93,3 +94,5 @@ export default function UnknownIcon({ /> ); } + +export default memo(UnknownIcon); diff --git a/client/src/components/Chat/Menus/Models/SpecIcon.tsx b/client/src/components/Chat/Menus/Models/SpecIcon.tsx index 5235dd4860d..9d1cb09e8e6 100644 --- a/client/src/components/Chat/Menus/Models/SpecIcon.tsx +++ b/client/src/components/Chat/Menus/Models/SpecIcon.tsx @@ -1,8 +1,9 @@ -import React from 'react'; +import React, { memo } from 'react'; import type { TModelSpec, TEndpointsConfig } from 'librechat-data-provider'; import type { IconMapProps } from '~/common'; import { getModelSpecIconURL, getIconKey, getEndpointField } from '~/utils'; import { icons } from '~/components/Chat/Menus/Endpoints/Icons'; +import { URLIcon } from '~/components/Endpoints/URLIcon'; interface SpecIconProps { currentSpec: TModelSpec; @@ -16,24 +17,12 @@ const SpecIcon: React.FC = ({ currentSpec, endpointsConfig }) => const iconKey = getIconKey({ endpoint, endpointsConfig, endpointIconURL }); let Icon: (props: IconMapProps) => React.JSX.Element; - if (!iconURL?.includes('http')) { + if (!iconURL.includes('http')) { Icon = icons[iconKey] ?? icons.unknown; + } else if (iconURL) { + return ; } else { - Icon = iconURL - ? () => ( -
- {currentSpec.name} -
- ) - : icons[endpoint ?? ''] ?? icons.unknown; + Icon = icons[endpoint ?? ''] ?? icons.unknown; } return ( @@ -42,9 +31,9 @@ const SpecIcon: React.FC = ({ currentSpec, endpointsConfig }) => endpoint={endpoint} context="menu-item" iconURL={endpointIconURL} - className="icon-lg mr-1 shrink-0 dark:text-white" + className="icon-lg mr-1 shrink-0 text-text-primary" /> ); }; -export default SpecIcon; +export default memo(SpecIcon); diff --git a/client/src/components/Chat/Messages/HoverButtons.tsx b/client/src/components/Chat/Messages/HoverButtons.tsx index fa7bd59ce08..0b27fc37658 100644 --- a/client/src/components/Chat/Messages/HoverButtons.tsx +++ b/client/src/components/Chat/Messages/HoverButtons.tsx @@ -50,9 +50,13 @@ export default function HoverButtons({ } = useGenerationsByLatest({ isEditing, isSubmitting, - message, + error: message.error, endpoint: endpoint ?? '', - latestMessage, + messageId: message.messageId, + searchResult: message.searchResult, + finish_reason: message.finish_reason, + isCreatedByUser: message.isCreatedByUser, + latestMessageId: latestMessage?.messageId, }); if (!conversation) { return null; @@ -146,7 +150,7 @@ export default function HoverButtons({ messageId={message.messageId} conversationId={conversation.conversationId} forkingSupported={forkingSupported} - latestMessage={latestMessage} + latestMessageId={latestMessage?.messageId} /> {continueSupported === true ? (