Giter VIP home page Giter VIP logo

chromeai's Introduction

Chrome AI

Stargazers Follow Twitter

Overview

Chrome AI is a demo project that runs large language models locally within the browser. It showcases the capabilities of modern web technologies to leverage advanced AI functionalities directly in the browser environment without needing server-side processing.

Features

  • Local Execution: Runs large language models directly in the browser.
  • Real-time Processing: Provides instant responses and interactions.
  • Privacy-focused: Processes data locally, ensuring user privacy and data security.

Getting Started

Prerequisites

  • Latest version of Google Chrome (127+) or any compatible Chromium-based browser.

How to Set Up Built-in Gemini Nano in Chrome

  1. Install Chrome Canary: Ensure you have version 127. Download Chrome Canary.
  2. Enable Prompt API: Open chrome://flags/#prompt-api-for-gemini-nano, set it to "Enabled".
  3. Enable Optimization Guide: Open chrome://flags/#optimization-guide-on-device-model, set it to "Enabled BypassPerfRequirement". Restart the browser.
  4. Download Model: Go to chrome://components/, find "Optimization Guide On Device Model", ensure it’s fully downloaded. If the version is "0.0.0.0", click "Check for update".
  5. Troubleshoot: If the "Optimization Guide On Device Model" is not displayed, disable the settings in steps 2 and 3, restart your browser and re-enable it.
  6. Verify Setup: Open a webpage, press F12, and check window.ai in the console.

Test Code:

const model = await window.ai.createTextSession();
await model.prompt("Who are you?");

Usage

Clone the repository:

git clone https://github.com/yourusername/chromeai.git
cd chromeai
pnpm i
pnpm dev

Open localhost:3000 in your browser to start using the AI.

Contributing

We welcome contributions! Please fork the repository and submit pull requests. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions or feedback, please contact Lightning Joyce on Twitter.

chromeai's People

Contributors

lightning-joyce avatar

Stargazers

obovoid avatar karyo avatar Rik Hoffbauer avatar kawamou avatar Katsuyuki Karasawa avatar Vasilis Bakas avatar Vaibhav Bansal avatar Tarun avatar Orest Khanenya avatar Eran Levy avatar Roger Kibbe avatar Krish Shah avatar zhounan avatar ghj1976 avatar Wildan Zulfikar avatar Damian Mee avatar Jwaxy avatar Benjamin Aster avatar  avatar 孔祥岩 avatar  avatar Tony Tang avatar livvy avatar Desmond avatar  avatar  avatar Joseph Mearman avatar  avatar xiansheng lu avatar roiwk avatar Roberto Gogoni avatar Rody Davis avatar Lance.Moe avatar Mike Staub avatar MOHANASUNDARAM K avatar  avatar  avatar Lin.Yao avatar  avatar Yoel Rosenthal avatar Eswaramoorthy Karthikeyan avatar Lewi Belayneh Haile  avatar kjch avatar Slawomir Wdowka avatar Hussain Fazaal avatar Ju avatar Dave Barnwell avatar  avatar Matija Grcic avatar Otto Borden avatar Ilya Subkhankulov avatar Juan P. Prieto avatar Jatin avatar pipizhu avatar Lsnsh Xin avatar  avatar Arnaud Didry avatar Allen Guo avatar  avatar profsquirrel avatar RiverRay avatar  avatar Latent Architect avatar isadora lopes avatar Mohamed Safouan Besrour avatar  avatar seung_ho_choi.s avatar Carlos Vieira avatar Alexandre Malfreyt avatar Sachiv Paruchuri avatar Ali Bakhtiari avatar Duc-Thien Bui avatar Mandar Badve avatar Zhao Qi avatar Kamolphan Lewprasert avatar Mark Hougaard avatar tuhana avatar  avatar  avatar Koolen Dasheppi avatar  avatar  avatar imesong avatar Loki avatar Ahmed Şeref avatar xyz avatar Yukai Huang avatar ziyao kang avatar Belem Zhang avatar  avatar  avatar Kuttesch avatar Cali (Renato Caliari) avatar sphynxlee avatar 远哥制造 avatar Ali Torki avatar  avatar nicekate avatar Andrej avatar @Captain avatar

Watchers

情封 avatar  avatar  avatar

chromeai's Issues

Component 'Optimization Guide On Device Model ' doesn't show up

Windows 11 Pro 22631.3880 - Windows Feature Experience Pack 1000.22700.1020.0
Chrome Canary v128.0.6589.0

Enabled WebGPU, prompt-api-for-gemini-nano and optimization-guide-on-device-model in all possible combinations and the Optimization Guide On Device Model isn't showing up even after restarting the browser or the PC.

image
image

Run time error "Unhandled Runtime Error TypeError: model.execute is not a function"

@lightning-joyce

In chrome canary 128.0.6589.0 (Official Build) canary (64-bit), when send prompt, there is a "Unhandled Runtime Error TypeError: model.execute is not a function" error

image

I fixed it in my local env, update code :

let aiReplay = (await model.execute(prompt)) as unknown as string;

to "let aiReplay = (await model.prompt(prompt)) as unknown as string;", it will works

New function request: Manually load the model

Hi, I found an internal page that might be able to manually load the model (chrome://on-device-internals/).
As I can't find a way to make the 'Optimization Guide On Device Model' option appear in chrome://components, I can't test that out myself.
I'm wondering if there's any way you might be able to perhaps provide a copy for the Gemini nano model so that users may load manually.

Component not showing up

I've followed all steps in the guide however on chrome://components, the required component is not shown. I've already set my primary language to english like mentioned in some guides but it doesn't show up nontheless.
image
chrome___components_

window.ai.createTextSession() has been renamed

Only for Canary Version: 130.0.6679.0 or above (check chrome://version)

As the title says, createTextSession is no longer valid in the newest canary version.

The new way to create a session is now:

const model = await window.ai.assistant.create()
await model.prompt("What is 2+2?"); // -> ' 2 + 2 = 4'

To get the ready state of the ai you would do:

const status = await window.ai.assistant.capabilities()
const ready = status.available

if (ready === 'readily') {
    // create ai session
} else {
    throw new Error('The AI is not ready!')
}

and lastly, before doing anything with the ai check if ai is a property to avoid errors:

const buildSupported = window.hasOwnProperty("ai") === true
if (buildSupported) {
   // Ai functions
}

A full example of how I would recommend the AI features here:

async function createAISession() {
    const buildSupported = window.hasOwnProperty("ai") === true
    if (buildSupported) {
        const status = await window.ai.assistant.capabilities()
        const ready = status.available
        if (ready === 'readily') {
            const model = await window.ai.assistant.create()
            return model;
        } else {
            throw new Error('The AI is not ready! Please try again later!')
        }
    } else {
        throw new Error('Your current chrome build doesn\'t support window.ai features. Please check the documentation and repeat the steps if you\'ve missed any')
    }
}

with this, the AI should be fully initialized and usable

  • thanks for reading.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.