GoogleChrome / chrome-extensions-samples

Chrome Extensions Samples
https://developer.chrome.com/docs/extensions
Apache License 2.0
15.35k stars 8.2k forks source link

Bug Report: 'ai.assistant' Functionality Issue in Google Chrome Canary v130 (Solution Available) #1324

Open Gitesh08 opened 9 hours ago

Gitesh08 commented 9 hours ago

Description Hey there👋 I've run into a problem with the ai.assistant feature in the ai.gemini-on-device extension sample. It's not working in Chrome Canary v130. The main issue seems to be that it can't create a session with await window.ai.assistant.create(), so the AI assistant is basically stuck. But don't worry - I've dug into it and I've got a fix ready to go!💪

You can find the extension code here if you need to take a look: functional-samples/ai.gemini-on-device.

To Reproduce🔄 Steps to reproduce the behavior, or file the issue is found in:

  1. Install Google Chrome Canary.

  2. Enable and use Gemini Nano and the Prompt API by following the setup instructions here.

  3. Clone the repository:

    git clone https://github.com/GoogleChromeLabs/chrome-for-testing.git
  4. Navigate to the extension directory:

    cd chrome-for-testing/extension-samples/on_device_inference
  5. Load this directory in Chrome as an unpacked extension:

  6. Open Chrome and go to chrome://extensions

  7. enable "Developer mode" in the top right.

  8. Click "Load unpacked" and select the on_device_inference directory

  9. Click the Chrome built-in AI extension icon.

  10. Try to use the prompt API in the sidebar.

Expected behavior The 'ai.assistant' feature should initialize successfully, create a session, and be ready to interact with the user, providing AI-assisted functionality as designed.

Screenshots📸 Screenshot

Proposed solution💡 I've already worked out a solution! Here's what I found and fixed:

  1. The issue was in the session creation process. It wasn't working with latest Chrome Canary v130.
  2. I've updated the code to use the new structure. The changes mainly involve adjusting how the session is created.
  3. I've tested the fix, and it's working great on my end. The AI assistant is now initializing properly and responding as expected.

You can refer below screenshot to check working status after changing codebase: Screenshot

Next Steps🚶‍♂️ I've got a working solution ready to go. Here's what I propose:

Wrapping Up Thanks for taking the time to read through this. I'm excited to help get this extension working smoothly again. Let me know if you'd like to see the specific changes or if you need any more information. Looking forward to getting this sorted out and merged in!

hemanth commented 7 hours ago

window.ai.assistant is now window.ai.languageModel

-- Thank you, Hemanth.HM http://www.h3manth.com

On Fri, Oct 18, 2024 at 10:13 AM Gitesh Mahadik @.***> wrote:

Description Hey there👋 I've run into a problem with the ai.assistant feature in the ai.gemini-on-device https://github.com/GoogleChromeLabs/chrome-for-testing/tree/main/extension-samples/on_device_inference extension sample. It's not working in Chrome Canary v130. The main issue seems to be that it can't create a session with await window.ai.assistant.create(), so the AI assistant is basically stuck. But don't worry - I've dug into it and I've got a fix ready to go!💪

You can find the extension code here if you need to take a look: functional-samples/ai.gemini-on-device https://github.com/GoogleChromeLabs/chrome-for-testing/tree/main/extension-samples/on_device_inference .

To Reproduce🔄 Steps to reproduce the behavior, or file the issue is found in:

  1. Install Google Chrome Canary https://www.google.com/intl/en_in/chrome/canary/.
  2. Enable and use Gemini Nano and the Prompt API by following the setup instructions here https://docs.google.com/document/d/1VG8HIyz361zGduWgNG7R_R8Xkv0OOJ8b5C9QKeCjU0c/edit?tab=t.0#heading=h.witohboigk0o .
  3. Clone the repository:

git clone https://github.com/GoogleChromeLabs/chrome-for-testing.git

  1. Navigate to the extension directory:

cd chrome-for-testing/extension-samples/on_device_inference

5.

Load this directory in Chrome as an unpacked extension: 6.

Open Chrome and go to chrome://extensions 7.

enable "Developer mode" in the top right. 8.

Click "Load unpacked" and select the on_device_inference directory 9.

Click the Chrome built-in AI extension icon. 10.

Try to use the prompt API in the sidebar.

Expected behavior The 'ai.assistant' feature should initialize successfully, create a session, and be ready to interact with the user, providing AI-assisted functionality as designed.

Screenshots📸 Screenshot.1037.png (view on web) https://github.com/user-attachments/assets/804e473d-3b5f-4340-bc01-8d58db17a0f4

Proposed solution💡 I've already worked out a solution! Here's what I found and fixed:

  1. The issue was in the session creation process. It wasn't working with latest Chrome Canary v130.
  2. I've updated the code to use the new structure. The changes mainly involve adjusting how the session is created.
  3. I've tested the fix, and it's working great on my end. The AI assistant is now initializing properly and responding as expected.

You can refer below screenshot to check working status after changing codebase: Screenshot.1039.png (view on web) https://github.com/user-attachments/assets/a3f76d8f-8af0-446b-b788-a0a4791dee8d

Next Steps🚶‍♂️ I've got a working solution ready to go. Here's what I propose:

  • I can submit a pull request with these changes if you'd like to review them.
  • If you want me to run any specific tests or provide more documentation, just let me know.
  • I'm happy to discuss the changes in more detail or make any adjustments based on your feedback.

Wrapping Up Thanks for taking the time to read through this. I'm excited to help get this extension working smoothly again. Let me know if you'd like to see the specific changes or if you need any more information. Looking forward to getting this sorted out and merged in!

— Reply to this email directly, view it on GitHub https://github.com/GoogleChrome/chrome-extensions-samples/issues/1324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEPCYQYCKT7M7F7BTUXMLZ4E6U3AVCNFSM6AAAAABQGLVEHSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4TQMBRHA3TGOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>