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

[Bug]: IncludeEnum not exported from TS package #3551

Closed
simonsmith opened this issue Jan 23, 2025 · 7 comments · Fixed by #3666
Closed

[Bug]: IncludeEnum not exported from TS package #3551

simonsmith opened this issue Jan 23, 2025 · 7 comments · Fixed by #3666
Labels
bug Something isn't working JavaScript question Further information is requested

Comments

@simonsmith
Copy link

simonsmith commented Jan 23, 2025

What happened?

Using version 1.10.4 of the chromadb package

Image

You cannot pass strings to include, so I try to use IncludeEnum (which is undocumented)

import {ChromaClient, DefaultEmbeddingFunction, IncludeEnum} from 'chromadb'

This works fine from the TS compiler perspective. It shows up correctly in my editor and when creating a build. But at runtime it seems the enum is not exported correctly

import { ChromaClient, DefaultEmbeddingFunction, IncludeEnum } from 'chromadb';
                                                 ^^^^^^^^^^^
SyntaxError: The requested module 'chromadb' does not provide an export named 'IncludeEnum'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)

Currently I have to just ignore the TS errors like so:

    include: [
      // @ts-expect-error IncludeEnum not exported
      'metadatas',
      // @ts-expect-error IncludeEnum not exported
      'documents',
      // @ts-expect-error IncludeEnum not exported
      'distances',
    ],

What is the recommended approach here? Perhaps easier to just use a type?

  type Include = 'documents' | 'metadatas' | 'distances'

  const example: Include[] = ['documents', 'metadatas', 'distances']

Thanks!

Versions

chromadb 0.6.2, installed using Python 3.13.1
version 1.10.4 of the chromadb JS package

Relates to #1332

Relevant log output

@simonsmith simonsmith added the bug Something isn't working label Jan 23, 2025
@tazarov
Copy link
Contributor

tazarov commented Jan 24, 2025

@simonsmith, have you tried this:

var res = await collection.get({
ids: id,
include: [IncludeEnum.Embeddings],
});

Note

The above is from our tests and it works fine without using any compiler hacks

@tazarov tazarov added JavaScript question Further information is requested labels Jan 24, 2025
@simonsmith
Copy link
Author

@tazarov Yes. My issue is as highlighted above, where it isn't exported from the package correctly. In your test example it's being imported locally, which isn't quite the same:

import { IncludeEnum } from "../src/types";

@tazarov
Copy link
Contributor

tazarov commented Jan 25, 2025

@simonsmith, so this doesn't work

export type {
IncludeEnum,

Is your project CJS or ESM so that I can debug this?

@eliasbiondo
Copy link

Same error here.

@simonsmith
Copy link
Author

I'll try and create a reproducible example for you

@tazarov
Copy link
Contributor

tazarov commented Feb 3, 2025

@simonsmith, @eliasbiondo, we found a problem with our exports using export type causing an issue in CJS projects as type info gets erased. Making it a regular export seems to fix the problem.

#3666 should address your issue. But while we release the JS client you can also refer to resolution here - #3661 (comment)

@simonsmith
Copy link
Author

@tazarov Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working JavaScript question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants