Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(community): Fix handling of ChromeAI chunks #7700

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

jtpio
Copy link
Contributor

@jtpio jtpio commented Feb 15, 2025

Trying to use ChromeAI with Chrome 133 (Version 133.0.6943.99 (Official Build) (arm64)) on MacOS seems to be giving very weird results:

image

Using the fix proposed in this PR (with patch-package locally to test more easily):

image

It's not clear if something changed in a later version of Chrome? It looks like it could be related to the new 133 release, since it was working fine with 132 before.


Below is a minimal app to reproduce the issue:

package.json

{
  "name": "langchainjs-minimal-example-chromeai",
  "private": true,
  "version": "0.0.1",
  "type": "module",
  "scripts": {
    "dev": "vite --debug",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@langchain/community": "^0.3.30",
    "@langchain/core": "^0.3.40"
  },
  "devDependencies": {
    "vite": "^5.0.8"
  }
}

main.js

import { ChromeAI } from "@langchain/community/experimental/llms/chrome_ai";

const model = new ChromeAI({
  temperature: 0.5,
  topK: 40,
});

document.getElementById('generate').addEventListener('click', async () => {
  const resultDiv = document.getElementById('result');
  resultDiv.textContent = 'Generating poem...';
  
  try {
    const response = await model.invoke("Write me a short poem please");
    resultDiv.textContent = response;
  } catch (error) {
    resultDiv.textContent = `Error: ${error.message}`;
  }
});

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>LangChain.js ChromeAI Example</title>
    <style>
      body {
        font-family: system-ui, -apple-system, sans-serif;
        max-width: 800px;
        margin: 0 auto;
        padding: 2rem;
      }
      button {
        padding: 0.5rem 1rem;
        margin: 1rem 0;
      }
      #result {
        white-space: pre-wrap;
        padding: 1rem;
        background: #f5f5f5;
        border-radius: 4px;
      }
    </style>
  </head>
  <body>
    <h1>LangChain.js ChromeAI Example</h1>
    <button id="generate">Generate Poem</button>
    <div id="result"></div>
    <script type="module" src="/main.js"></script>
  </body>
</html>

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 15, 2025
Copy link

vercel bot commented Feb 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ❌ Failed (Inspect) Feb 15, 2025 0:19am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Feb 15, 2025 0:19am

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Feb 15, 2025
@jacoblee93
Copy link
Collaborator

Yes likely a breaking change on their end given it's in very early beta - thanks for flagging!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Feb 18, 2025
@jacoblee93 jacoblee93 changed the title fix(chromeai): Fix handling of chunks fix(community): Fix handling of ChromeAI chunks Feb 18, 2025
@jacoblee93 jacoblee93 merged commit b5a8249 into langchain-ai:main Feb 18, 2025
31 of 32 checks passed
@jtpio jtpio deleted the fix-chromeai branch February 18, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature lgtm PRs that are ready to be merged as-is size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants