diff --git a/plugins/azure/shieldPrompt.ts b/plugins/azure/shieldPrompt.ts index a86d07178..25069b932 100644 --- a/plugins/azure/shieldPrompt.ts +++ b/plugins/azure/shieldPrompt.ts @@ -79,7 +79,9 @@ export const handler = async ( const request = { userPrompt, - ...(systemMessages.length > 0 ? { documents: textArray } : {}), // If system message, add user prompt as documents + ...(Array.isArray(systemMessages) && systemMessages.length > 0 + ? { documents: textArray } + : {}), // If system message, add user prompt as documents }; const apiVersion = parameters.apiVersion || '2024-09-01';