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

DOC-4199: add TCEs to the combined query page #2838

Conversation

dwdougherty
Copy link

Description

Tabbed code examples (TCEs) for the combined query page. Please merge as soon as possible.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

doctests/query-combined.js Outdated Show resolved Hide resolved
doctests/query-combined.js Outdated Show resolved Hide resolved
normalize: true,
});

const embedding = Object.values(vectorOutput?.data);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will throw an error if vectorOutput is undefined (which seems to be an option since you are using .?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the change you want me to make here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never used the @xenova/transformers package, but because you've used the .? I guess the function returns undefined in some cases (?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno. I stole that code from another set of examples.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @leibale point is that the pipeline can seemingly return an undefined and then you would be passing an undefined into Object.values(), which will result in an exception.

Now, if this were just to be a test, that probably wouldn't be a huge problem (as the exception would fail the test), but if this is also suppoesd to be documentation on how to use it, perhaps a check for it being undefined with a throw error if it is, would help (and then wouldn't need the ?, as the if undefined check would restrict it away).

just a thought, could be wrong :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test around vectorOutput and removed the '?' from the assignment as suggested.

doctests/query-combined.js Outdated Show resolved Hide resolved
doctests/query-combined.js Show resolved Hide resolved
doctests/query-combined.js Outdated Show resolved Hide resolved
doctests/query-combined.js Outdated Show resolved Hide resolved
doctests/query-combined.js Outdated Show resolved Hide resolved
@sjpotter
Copy link
Contributor

pacakges.json doesn't seem to include xenova/transformers.

@dwdougherty dwdougherty closed this by deleting the head repository Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants