chroma icon indicating copy to clipboard operation
chroma copied to clipboard

[ENH] AmazonBedrockEmbeddingFunction for JS

Open chezou opened this issue 1 year ago • 12 comments

Description of changes

Summarize the changes made by this PR.

  • New functionality
    • Add AmazonBedrockEmbeddingFunction for JS. Follow up https://github.com/chroma-core/chroma/pull/1361

Test plan

  • [x] Tests pass locally with pytest for python, yarn test for js

Also, manually tested with node:

$ npx node
Welcome to Node.js v18.17.1.
Type ".help" for more information.
> const { fromSSO } = require('@aws-sdk/credential-providers');
> const { AmazonBedrockEmbeddingFunction} = require('chromadb')
> var c = await fromSSO({profile: "my-profile"})
> var ef = new AmazonBedrockEmbeddingFunction({config: {credentials: c, region: "us-east-1"}})
> var emb = await ef.generate(["foo"])
> emb
[
  [
     -0.033203125,  -0.15722656,  -0.21386719,   -0.080078125,
      0.061035156,  -0.26171875,      0.78125, -0.00090408325,
      0.119140625, -0.060058594,   0.96484375,        0.65625,
        0.3203125,  -0.24707031,  -0.49414062,     0.66796875,
             -0.5,   -1.0546875,   -0.7578125,        0.53125,
      -0.25585938,    0.5234375,   0.16601562,      1.2421875,
       0.34765625,   0.69140625,   0.32226562,     0.14550781,
         0.890625,  -0.46679688,   0.12011719,      -0.859375,
     -0.087890625,    -0.546875,   -0.1953125,     -1.3671875,
       0.34570312,   -1.3046875,  -0.13476562,    -0.47070312,
       0.43359375,  -0.47851562,    1.2578125,     0.44140625,
      -0.36914062,  -0.69921875,   0.16308594,     0.65234375,
      -0.40820312,  0.111328125, -0.026855469,    0.039794922,
       -0.8515625,  -0.08251953,   0.13574219,      0.7578125,
       0.21679688,   0.25585938,   -0.4296875,    -0.45898438,
               -1,  -0.51171875,   0.31054688,    -0.74609375,
      0.030151367,  -0.46484375,  -0.62109375,     0.58203125,
       -1.1015625,     0.515625, -0.111328125,   -0.076171875,
         0.796875,  -0.64453125,     0.921875,     0.27148438,
          0.71875,    0.1953125,   0.17578125,     0.90234375,
      -0.37695312,   0.33203125,  0.018066406,   -0.009094238,
       0.12890625,   0.34179688,    0.6796875,    -0.19335938,
    0.00012207031,   0.75390625,       -0.125,     0.94921875,
        1.2734375,   0.26757812,  -0.25976562,     0.83203125,
      -0.57421875,  -0.87109375, -0.020629883,        0.46875,
    ... 1436 more items
  ]
]

Documentation Changes

Will update chroma-core/docs later.

chezou avatar Jan 20 '24 08:01 chezou

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • [ ] Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • [ ] Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • [ ] If appropriate, are there adequate property based tests?
  • [ ] If appropriate, are there adequate unit tests?
  • [ ] Should any logging, debugging, tracing information be added or removed?
  • [ ] Are error messages user-friendly?
  • [ ] Have all documentation changes needed been made?
  • [ ] Have all non-obvious changes been commented?

System Compatibility

  • [ ] Are there any potential impacts on other parts of the system or backward compatibility?
  • [ ] Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • [ ] Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

github-actions[bot] avatar Jan 20 '24 08:01 github-actions[bot]

I added a change to ensure the default region, otherwise, the client returns error https://github.com/chroma-core/chroma/pull/1659/commits/fa9746fb2e5d9e852d419033ad4e02e5606d3036

I'll add a test for this embedding function later.

chezou avatar Jan 21 '24 17:01 chezou

Added a test for the function https://github.com/chroma-core/chroma/pull/1659/commits/6ef9154b1d84f2a61b07d44a6c5479b55bf2eaf8

chezou avatar Jan 22 '24 01:01 chezou

@tazarov Can you allow to run tests?

chezou avatar Jan 28 '24 03:01 chezou

@chezou im not sure why tests aren't running 🤔 can you tack on an extra commit here to trigger them? thank you! my apologies for the delay here

jeffchuber avatar Feb 27 '24 13:02 jeffchuber

@jeffchuber Thanks! Created an empty commit b7425e879ead8e7b51f04af09104ec16e323b5b2, but it looks approval for run is required image

chezou avatar Feb 27 '24 15:02 chezou

Fixed the PR title since "Check PR Title" was failed.

chezou avatar Mar 13 '24 23:03 chezou

tests will now re-run with the merge conflicts handled. sorry about the PR title issue

jeffchuber avatar Mar 14 '24 00:03 jeffchuber

@tazarov @jeffchuber If there's no issue, could you approve and merge this PR?

chezou avatar Apr 03 '24 16:04 chezou

@chezou, do you mind resolving the conflict?

tazarov avatar Apr 16 '24 10:04 tazarov

@tazarov Resolved

chezou avatar Apr 16 '24 14:04 chezou

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

Name Status Preview Comments Updated (UTC)
chroma ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 5:05am

vercel[bot] avatar May 03 '24 04:05 vercel[bot]

Our underlying impl has changed and so this PR is not landable as is.

That being said - we'd still like to add this functionality and that is now tracked in this issue.

jeffchuber avatar Sep 15 '24 20:09 jeffchuber