Skip to content

Commit 3c7146b

Browse files
authored
Merge pull request #633 from google-ai-edge/tyrmullen-patch-2
web gemma 3n demo: non-chromium alert message
2 parents 0c853a9 + 4a0b49c commit 3c7146b

File tree

1 file changed

+9
-0
lines changed
  • examples/llm_inference/hugging_face_js/gemma_3n

1 file changed

+9
-0
lines changed

examples/llm_inference/hugging_face_js/gemma_3n/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ async function pipeStreamAndReportProgress(readableStream, writableStream) {
183183
* Loads the LLM file from either cache or OAuth-guarded remote download.
184184
*/
185185
async function loadLlm() {
186+
// For browsers other than Chrome and Edge, we just show an alert and error out.
187+
const isChrome = navigator.userAgent.includes('Chrome');
188+
const isEdge = navigator.userAgent.includes('Edg');
189+
if (!isChrome && !isEdge) {
190+
alert('Non-Chromium browsers are not supported yet. Please run demo on Chrome for the best experience.');
191+
loaderMessage.textContent = "Non-Chromium browsers are not supported yet. Please run on Chrome for best experience.";
192+
return;
193+
}
194+
186195
let opfs = await navigator.storage.getDirectory();
187196
// If we can load the model from cache, then do so.
188197
try {

0 commit comments

Comments
 (0)