-
-
Notifications
You must be signed in to change notification settings - Fork 340
Vector example with @orama/plugin-embeddings not working #925
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
Comments
Just ran into this! It's a problem with Orama's bundler.
Orama switches into a special mode when it detects that hook as an async function:
That's done by looking at the function's constructor: orama/packages/orama/src/utils.ts Line 355 in c8051ce
But...Orama's bundler converts it away from an async function! If you look at the code published to npm, you'll see that
This is not an async function, because it was transformed by the bundler! |
As a workaround, you can do this:
|
Hey @lights0123 that's a nice catch... any suggestion for a fix at the bundler level? |
Async functions are part of ES7, and your bundler tsup reads tsconfig.json so it should be as simple as changing this line to ES7:
You'll also need to add to your documentation that users should configure their bundlers in the same way, as they typically re-process files. This drops support for IE11. However, I think it would be better to just re-write some logic to look at the return type of the function—I don't really like that orama/packages/orama/src/components/hooks.ts Lines 95 to 106 in c8051ce
with (untested): let promise: Promise<void> | undefined;
for (const hook of hooks) {
if (promise) {
// If we already have a promise chain, extend it
// by running the current hook after previous promises resolve
promise = promise.then(() => hook(db, params, language));
} else {
// First hook or no promises yet
const result = hook(db, params, language);
if (typeof result?.then === 'function') {
// Start a promise chain
promise = result;
}
}
}
return promise; |
Describe the bug
Hi,
it seems that the second example, the one using
@orama/plugin-embeddings
does not work as expected.From what I can see:
insert
andsearch
vector
is being defined here or use another import.Also check the first example. It imports
remove‘ and
searchVector’ but doesn't use them. It's not a big deal, but I think it's better to remove them or add some code that uses them for better understanding.Regards,
Diego
To Reproduce
Just try the example with
@orama/plugin-embeddings
Expected behavior
To run without issues
Environment Info
Affected areas
Initialization, Search
Additional context
No response
The text was updated successfully, but these errors were encountered: