From f69b31717199930f629c12066ebb3a4627b54194 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:56:15 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(useMentions):=20handle=20emp?= =?UTF-8?q?ty=20assistant=20lists=20(#2966)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The useMentions hook in the client/src/hooks/Input/useMentions.ts file has been updated to handle cases where the assistant lists for the endpoints 'assistants' and 'azureAssistants' are empty. This change ensures that the hook does not throw an error when attempting to access assistantListMap[EModelEndpoint.assistants] or assistantListMap[EModelEndpoint.azureAssistants]. Instead, it defaults to an empty array for these cases. --- client/src/hooks/Input/useMentions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/hooks/Input/useMentions.ts b/client/src/hooks/Input/useMentions.ts index 3cb616acae..75f85e567a 100644 --- a/client/src/hooks/Input/useMentions.ts +++ b/client/src/hooks/Input/useMentions.ts @@ -121,10 +121,10 @@ export default function useMentions({ assistantMap }: { assistantMap: TAssistant }), })), ...(endpointsConfig?.[EModelEndpoint.assistants] - ? assistantListMap[EModelEndpoint.assistants] + ? assistantListMap[EModelEndpoint.assistants] || [] : []), ...(endpointsConfig?.[EModelEndpoint.azureAssistants] - ? assistantListMap[EModelEndpoint.azureAssistants] + ? assistantListMap[EModelEndpoint.azureAssistants] || [] : []), ...((interfaceConfig.presets ? presets : [])?.map((preset, index) => ({ value: preset.presetId ?? `preset-${index}`,