🔧 fix(useMentions): handle empty assistant lists (#2966)

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.
This commit is contained in:
Marco Beretta 2024-06-05 20:56:15 +02:00 committed by GitHub
parent 4469ba72fc
commit f69b317171
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}`,