From de2d5c59058169c1607828c421f1445d16795213 Mon Sep 17 00:00:00 2001 From: Sebastian Benz Date: Mon, 26 Aug 2024 12:17:30 +0200 Subject: [PATCH] show correct error when ai is not supported in browser --- .../ai.gemini-on-device-summarization/sidepanel/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functional-samples/ai.gemini-on-device-summarization/sidepanel/index.js b/functional-samples/ai.gemini-on-device-summarization/sidepanel/index.js index 0342bf5af6..242b8c04d1 100644 --- a/functional-samples/ai.gemini-on-device-summarization/sidepanel/index.js +++ b/functional-samples/ai.gemini-on-device-summarization/sidepanel/index.js @@ -56,8 +56,8 @@ async function generateSummary(text) { } async function createSummarizationSession(downloadProgressCallback) { - if (!window.ai.summarizer) { - throw new Error('AI Summarization is not supported'); + if (!window.ai || !window.ai.summarizer) { + throw new Error('AI Summarization is not supported in this browser'); } const canSummarize = await window.ai.summarizer.capabilities(); if (canSummarize.available === 'no') {