🔧 fix: EndpointIcon crash when using @ mention command (#3742)

This commit is contained in:
Danny Avila 2024-08-22 10:49:51 -04:00 committed by GitHub
parent 596ecc6969
commit 366e4c5adb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,40 +31,42 @@ export default function EndpointIcon({
const endpointType = getEndpointField(endpointsConfig, endpoint, 'type'); const endpointType = getEndpointField(endpointsConfig, endpoint, 'type');
const endpointIconURL = getEndpointField(endpointsConfig, endpoint, 'iconURL'); const endpointIconURL = getEndpointField(endpointsConfig, endpoint, 'iconURL');
const assistant = const assistant = isAssistantsEndpoint(endpoint)
isAssistantsEndpoint(endpoint) && assistantMap?.[endpoint]?.[conversation?.assistant_id ?? '']; ? assistantMap?.[endpoint]?.[conversation?.assistant_id ?? '']
const assistantAvatar = (assistant && (assistant?.metadata?.avatar as string)) || ''; : null;
const assistantName = (assistant && assistant?.name) || ''; const assistantAvatar = (assistant && (assistant.metadata?.avatar as string)) || '';
const assistantName = assistant && (assistant.name ?? '');
const iconURL = assistantAvatar || convoIconURL; const iconURL = assistantAvatar || convoIconURL;
let icon: React.ReactNode | null = null;
if (iconURL && (iconURL.includes('http') || iconURL.startsWith('/images/'))) { if (iconURL && (iconURL.includes('http') || iconURL.startsWith('/images/'))) {
icon = ConvoIconURL({ return (
preset: { <ConvoIconURL
...(conversation as TPreset), preset={{
iconURL, ...(conversation as TPreset),
}, iconURL,
context, }}
endpointIconURL, context={context}
assistantAvatar, endpointIconURL={endpointIconURL}
assistantName, assistantAvatar={assistantAvatar}
}); assistantName={assistantName ?? ''}
/>
);
} else { } else {
icon = MinimalIcon({ return (
size: 20, <MinimalIcon
iconURL: endpointIconURL, size={20}
endpoint, iconURL={endpointIconURL}
endpointType, endpoint={endpoint}
model: conversation?.model, endpointType={endpointType}
error: false, model={conversation?.model}
className, error={false}
isCreatedByUser: false, className={className}
chatGptLabel: undefined, isCreatedByUser={false}
modelLabel: undefined, chatGptLabel={undefined}
jailbreak: undefined, modelLabel={undefined}
}); jailbreak={undefined}
/>
);
} }
return icon;
} }