Commit Graph

72 Commits

Author SHA1 Message Date
Jeff Huber
aae36f57b1 JS Improvements (#649)
This PR has a few fixes
- fix the JS examples to `1.5.1` and add documentation for CORS 
- add a test for `queryTexts` with a stubbed out embedding function
2023-07-08 00:25:48 +00:00
Luke VanderHart
13bf3e070f API implementation for segment-based architecture (#662)
## Description of changes

New API implementation backed by the segment-based architecture. Should
be extensible to a full distributed architecture.

---------

Co-authored-by: Jeffrey Huber <jeff@trychroma.com>
Co-authored-by: hammadb <hammad@trychroma.com>
Co-authored-by: Anton Troynikov <atroyn@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hammad Bashir <HammadB@users.noreply.github.com>
2023-07-05 11:56:39 -07:00
Jeff Huber
11d80a4b63 bump JS to fix cohere embedding function (#742)
bump, already released
2023-07-04 12:52:37 -07:00
Jeff Huber
f92ed424e0 fix port str (#758)
found b/c of this PR against docs
https://github.com/chroma-core/docs/pull/91
2023-07-04 12:34:24 -07:00
Timothy Carambat
e69abfcb21 Enable custom JS Client headers during request to Chroma Instance (#728)
connect #725

## Description of changes
Add a new `fetchOptions` parameter on the JS ChromaClient creation that
allows you to pass in custom `fetch` options.

Example:
```
const chroma = new ChromaClient({
  path: "http://localhost:8000",
  fetchOptions: {
    headers: {
      'X-Api-Token': "sk-live-Hunt3r2", // Works like regular node-fetch headers!
    }
  }
});
```

## Test plan
The existing test suite was run and validated as passing. 

## Documentation Changes
Typescript would allow the developer to know that these options are
available. I do not think it currently requires updates to the Chroma
Documentation - especially since this change is only impacting the JS
client.

---------

Co-authored-by: Jeffrey Huber <jeff@trychroma.com>
2023-06-27 23:43:26 -07:00
Tõnis Tiganik
e6cb2adad9 fix cohere api key (#726)
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Fixes cohere embeddings not using the api key.

## Test plan
* I tested that cohere embeddings returned a result
* Without this change the result is undefined

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
no
2023-06-26 13:22:57 -07:00
Suhas Deshpande
dedebb9624 update client usage in example (#724)
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - changes the client usage in example
2023-06-23 09:52:59 -07:00
Jeff Huber
889c0bf1d5 fix JS Where type, closes #718 (#722)
fixes #718
2023-06-21 21:32:20 -07:00
Joshua Lochner
974cc7d105 Add embedding support for Transformers.js (#664)
## Description of changes

*Summarize the changes made by this PR.*
 - New functionality
- Add support for
[Transformers.js](https://github.com/xenova/transformers.js). This
allows users to run Hugging Face transformers directly from their JS
applications. For more information, see
https://huggingface.co/docs/transformers.js.

## Test plan
*How are these changes tested?*
I followed the [JS "Getting started"
guide](https://docs.trychroma.com/getting-started?lang=js) to ensure it
works as intended. Here's the script, and its output:
```js
const {ChromaClient, TransformersEmbeddingFunction} = require('chromadb');
const client = new ChromaClient();

// Create the embedder. In this case, I just use the defaults, but you can change the model,
// quantization, revision, or add a progress callback, if desired.
const embedder = new TransformersEmbeddingFunction({ /* Configuration goes here */ });

const main = async () => {
    // Empties and completely resets the database.
    await client.reset()

    // Create the collection
    const collection = await client.createCollection({name: "my_collection", embeddingFunction: embedder})

    // Add some data to the collection
    await collection.add({
        ids: ["id1", "id2", "id3"],
        metadatas: [{"source": "my_source"}, {"source": "my_source"},  {"source": "my_source"}],
        documents: ["I love walking my dog", "This is another document", "This is a legal document"],
    }) 
    
    // Query the collection
    const results = await collection.query({
        nResults: 2, 
        queryTexts: ["This is a query document"]
    }) 
    console.log(results)
    // {
    //     ids: [ [ 'id2', 'id3' ] ],
    //     embeddings: null,
    //     documents: [ [ 'This is another document', 'This is a legal document' ] ],
    //     metadatas: [ [ [Object], [Object] ] ],
    //     distances: [ [ 1.0109775066375732, 1.0756263732910156 ] ]
    // }
}

main();

```


## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
I just added some type annotations for the constructor.
2023-06-21 14:41:58 -07:00
Anton Troynikov
bad9597f6d Fail validation for bools in metadata (#672)
## Description of changes

It turns out `isinstance(bool, int)` returns True. We need to test for
`bool` separately.

Addresses the first part of
https://github.com/chroma-core/chroma/issues/671

## Test plan
A new test, `test_boolean_metadata`, marked xfail.  

## Documentation Changes
None. This now matches the documentation.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-21 14:35:08 -07:00
Jeff Huber
ec54cfb6df js 1.5.2 (#663)
Bump JS to 1.5.2 to pick up the types changes to unblock langchainjs. 

This has already been released to npm.
2023-06-02 14:44:25 -07:00
Russell Pollari
b50ae87f1d Fix incorrect types in QueryResponse (#661)
## Description of changes

 - Improvements & Bug fixes
- Fix incorrect types for `embeddings` and `distances` in
`QueryResponse`
	 - closes: #660 

## Test plan
Tests ran and passed

## Documentation Changes
None

Co-authored-by: russell-pollari <pollarir@mgail.com>
2023-06-02 14:06:01 -07:00
Alexander Visheratin
1c7dba3f89 Web AI embedder for JS library (#633)
## Description of changes

Added a new JavaScript embedding function to generate embeddings for
text and images using the [Web AI](https://github.com/visheratin/web-ai)
library. The users will now be able to generate the embeddings in both
NodeJS and (IMO more importantly) in the browser. This, along with the
existing JS library design, enables the decoupling of embeddings
generation from storage (see example demo below).

## Test plan

I created a demo to check how the function works in web apps -
https://web-ai-chroma.vercel.app/

The embeddings are generated on the client side and sent to the server
to add to the collection or query for similar items.

## Documentation Changes

Likely this change will require changes in the documentation.
2023-05-31 23:26:33 -07:00
Russell Pollari
7405478f4b Catch and throw error in ChromaClient.getCollection (#647)
## Description of changes
When fetching a collection that does not exist, the JS client would fail
silently, returning a collection with `undefined` for all its
attributes.

 - Improvements & Bug fixes
- `ChromaClient.getCollection` will throw an error if there is an error
in the API response
	 - closes: #634 

## Test plan
Passed tests with `$ yarn test`

## Documentation Changes
None

---------

Co-authored-by: russell-pollari <pollarir@mgail.com>
2023-05-31 22:16:07 -07:00
Hammad Bashir
bdc1841e22 Add a thin client (#610)
## Description of changes
*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Typing cleanup
- Changes embedding function defaults to work through the default params
as opposed to via None so that None now means - NO embedding function as
opposed to use the default. This is technically a breaking change.
 - New functionality
- Adds a thin client that restricts what you can create to the REST api
client and builds it separately so it can be published to its own pypi
package. The thin client restricts the default embedding function to be
None always - forcing manual specification of the embedding function
while using the thin client.
- The thin client is built with its own pyproject.toml with a limited
set of dependencies and a is_thin_client.py file that acts as a compile
flag. The build script stages the toml, places the two files in the
right place, performs the build and then tears down the changes.
	 
Addresses #289 

## Test plan
The existing tests should cover this configuration. We can add CI for
the thin-client in the future.

## Documentation Changes
We will add a section on the docs that explains the thin client and its
limitations.
2023-05-31 14:23:10 -07:00
Jeff Huber
bfe9fe7b6a bump JS version and update release process (#643)
Update our release process for JS to avoid missing a fresh build.
2023-05-30 16:55:16 -07:00
Jeff Huber
e406efde2d bump JS to 1.5.0 (#607)
Since our release process is manual - this does not need to land before
release.
2023-05-22 15:42:34 -07:00
Jeff Huber
565f2e4fb8 switch to camelcase inputs (#587)
Switch from `snake_case` to `camelCase` for JS named inputs
2023-05-19 14:11:33 -07:00
ishan
db0af40e17 Chroma core/chrome 536 (#568)
## Description of changes

Please let me know if anything needs to be changed or done differently!
We can certainly continue to make efforts to make our JS client more
structured and maintainable.

*Summary:*
 - Improvements & Bug fixes
	 - Broke `client/js/src/index.ts` down and put them in separate files
- Created `IEmbeddedFunction` interface to improve the maintainability
and extensibility of the client code, making it easier to add new
embedding function types in the future
	 - Replaced `CallableFunction` with `IEmbeddingFunction`
- Closes #536
 - New functionality
	 - None

## Test plan
Refactored tests 
**Note:** the Collection tests have been failing on main when I run
using `yarn test`, did we know about this?

## Documentation Changes
Not sure, couldn't find anything?
2023-05-18 22:03:14 -07:00
Jeff Huber
b5826d1072 switch to named params for JS client (#513)
In this PR
- docstrings! 
- types!
- named params! 

This is a breaking change to the JS Client - it switches from positional
to named arguments originally brought up by @transitive-bullshit in
https://github.com/chroma-core/chroma/issues/254

Example: 

```
// before
const collection = await chroma.createCollection("test");

//after
const collection = await chroma.createCollection({ name: "test" });
```

This is especially nice when you are only using a few params. 

This PR does not bump the `npm` version number - we will cut a new
release on Monday.

We will need to land an update to our docs at that time as well. TBD
2023-05-17 09:39:20 -07:00
Jeff Huber
6ec5d7a169 bump to 1.4.2. (#552)
Bump npm to 1.4.2 for release today
2023-05-16 09:26:42 -07:00
Jeff Huber
d493ef6ea0 Merge branch 'main' into patch-5 2023-05-11 15:10:31 -07:00
Hammad Bashir
c17249b818 Add precommit hooks (#483)
Adds precommit hooks based on #433 to our repository. Only one file here is new - the configuration for the hooks, everything else is linting/formatting fixes. We do not run the typechecker globally since that would be quite lengthy to clean up - instead we will have to incrementally clean up type check issues as we go.
2023-05-10 05:52:12 +00:00
Luke VanderHart
8ce3362157 fix merge error in ts client 2023-05-08 11:45:35 -04:00
Luke VanderHart
c2fb9a8ecb fixes for ts client tests 2023-05-08 11:42:49 -04:00
Luke VanderHart
5cc02d09dc fix error in TS client impl 2023-05-08 11:42:37 -04:00
Luke VanderHart
67a83127d8 update js client to use collection id 2023-05-08 11:11:14 -04:00
Hammad Bashir
f9b8f7c3b7 Team/hypothesis tests (#474)
Merges the team/hypothesis-tests branch to main. Which adds a robust property-based testing suite to Chroma. lfg.
2023-05-05 21:03:15 -07:00
Jeffrey Huber
5f641bd0cb remove unused type 2023-05-02 22:51:29 -07:00
Jeffrey Huber
658f3dc4bf make version api non-breaking change 2023-04-22 11:04:12 -07:00
Jeffrey Huber
8b6f4a614f swap from axios to fetch 2023-04-22 08:52:03 -07:00
naynaly10
50a826be11 Rolled back CohereEmbeddingFunction parameter rename 2023-04-22 01:20:17 -05:00
naynaly10
f01f3cfd43 Rollback OpenAIEmbeddingFunction parameter rename. 2023-04-21 23:33:09 -05:00
naynaly10
adbd18318b Updated parameter names for simplicity. e.g. "cohere_model" to "model" 2023-04-21 22:28:15 -05:00
Jeff Huber
b96fc387f9 Merge pull request #381 from naynaly10/patch-4
Fix OpenAIEmbeddingFunction in JS to use passed model name
2023-04-21 17:45:04 -07:00
Greg Solovyev
d9d19f4c0f move chroma.reset to beforeEach hook 2023-04-20 19:28:51 -07:00
Greg Solovyev
2c798521ae Fix local tests
- specify larger timeout in jest config
 - use an env variable to specify chroma port
2023-04-20 19:26:19 -07:00
naynaly10
e5ad536074 Update index.ts
Added ability to configure cohere model type.
2023-04-18 21:09:56 -05:00
naynaly10
893b5d8e80 Update index.ts
Class OpenAIEmbeddingFunction() is initiated with an optional parameter - model (string). But inside the generate() function of the class, the optional parameter is forgotten to be used when making API Call to OpenAI. Instead of the parameter, a string literal "text-embedding-ada-002" is used.
2023-04-18 20:55:33 -05:00
Jeffrey Huber
65fd786919 bump version 2023-04-18 10:36:50 -07:00
Jeffrey Huber
0ccfc5455b add additional JS tests 2023-04-14 21:59:01 -07:00
Jeffrey Huber
238da80d15 refactor tests 2023-04-10 22:01:50 -07:00
Jeffrey Huber
a46776d40e add update embedding and modify collection 2023-04-09 23:01:04 -07:00
Jeffrey Huber
41936047fa bump 2023-04-04 20:39:23 -07:00
Jeffrey Huber
757c2886c4 try gh actions js tests' 2023-04-04 15:07:46 -07:00
Jeff Huber
9559eba28c Merge pull request #261 from chroma-core/jsTestsFix
fix js tests, fix bug with index deletion
2023-03-30 13:00:16 -07:00
Jeffrey Huber
de9c29ab1b cleanup 2023-03-30 11:33:58 -07:00
Jeffrey Huber
0d2e61b17f fix js tests, fix bug with index deletion 2023-03-30 11:16:46 -07:00
Jeffrey Huber
190c3b40da update browser example readme 2023-03-29 12:23:58 -07:00
Ikko Eltociear Ashimine
bbd97834b1 fix typo in DEVELOP.md (#231)
programatically -> programmatically
2023-03-24 17:48:05 -07:00