-
Notifications
You must be signed in to change notification settings - Fork 2k
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
hnswlib: Throw error in index getter to dedupe code and have safer usage #35
hnswlib: Throw error in index getter to dedupe code and have safer usage #35
Conversation
1c6452e
to
698e840
Compare
Great call! This cleans things up nicely. |
Another option would be to make the index property private, if you need access to it you can always create the instance with an index created outside? |
Yeah you could make it private, and you could use
|
698e840
to
6436cbc
Compare
Thanks so much for this @micahriggan , I've rebased this and pulling this in now |
* Use fetch adapter for openai axios * Update tsc build to output ESM only * Update all import paths to have extension per ESM requirements * Move all source files to src/ * Remove circular dependency * Fix jest config for ESM * Remove circular deps not possible with ESM * Throw error in index getter to dedupe code and have safer usage (#35) * Fix hnsw for esm * Fix usage of hnswlib with index passed in * Fix textsplitter for esm * Fix openai for esm * Fix hf for esm * Fix ESM for cohere * Fix ESM for serpapi * Fix esm in srt * Remove dependency on @vespaiach/axios-fetch-adapter which has an incorrect export * Fix examples for esm * Fix entrypoints * Fix test-exports for esm * Add fetch flag for node 16 ci job * Add a more thorough test for packaging * Fix docs build --------- Co-authored-by: micahriggan <micahriggan@users.noreply.github.com>
* Add integration tests GH action (manual trigger for now), reduce cost of integration tests by using smallest possible models * Convert library to ESM codebase, ESM output (#124) * Use fetch adapter for openai axios * Update tsc build to output ESM only * Update all import paths to have extension per ESM requirements * Move all source files to src/ * Remove circular dependency * Fix jest config for ESM * Remove circular deps not possible with ESM * Throw error in index getter to dedupe code and have safer usage (#35) * Fix hnsw for esm * Fix usage of hnswlib with index passed in * Fix textsplitter for esm * Fix openai for esm * Fix hf for esm * Fix ESM for cohere * Fix ESM for serpapi * Fix esm in srt * Remove dependency on @vespaiach/axios-fetch-adapter which has an incorrect export * Fix examples for esm * Fix entrypoints * Fix test-exports for esm * Add fetch flag for node 16 ci job * Add a more thorough test for packaging * Fix docs build --------- Co-authored-by: micahriggan <micahriggan@users.noreply.github.com> --------- Co-authored-by: micahriggan <micahriggan@users.noreply.github.com>
…rt library to ESM codebase, ESM output (#124), Add GH (manual) action for running integration tests (#119) * Use fetch adapter for openai axios * Remove node-fetch, add instructions for node 16 * Add GH (manual) action for running integration tests (#119) * Add integration tests GH action (manual trigger for now), reduce cost of integration tests by using smallest possible models * Convert library to ESM codebase, ESM output (#124) * Use fetch adapter for openai axios * Update tsc build to output ESM only * Update all import paths to have extension per ESM requirements * Move all source files to src/ * Remove circular dependency * Fix jest config for ESM * Remove circular deps not possible with ESM * Throw error in index getter to dedupe code and have safer usage (#35) * Fix hnsw for esm * Fix usage of hnswlib with index passed in * Fix textsplitter for esm * Fix openai for esm * Fix hf for esm * Fix ESM for cohere * Fix ESM for serpapi * Fix esm in srt * Remove dependency on @vespaiach/axios-fetch-adapter which has an incorrect export * Fix examples for esm * Fix entrypoints * Fix test-exports for esm * Add fetch flag for node 16 ci job * Add a more thorough test for packaging * Fix docs build --------- Co-authored-by: micahriggan <micahriggan@users.noreply.github.com> --------- Co-authored-by: micahriggan <micahriggan@users.noreply.github.com> * Fix one more import * Fix example * Also build docs in ci * Fix sql test in ci --------- Co-authored-by: micahriggan <micahriggan@users.noreply.github.com>
Feel free to close, but seems like we can provide safer access to .index with a getter that throws if it hasn't been init'd
Also added a static method to init the HNSW Lib so we don't have to dupe the error handling each time
Oh yeah, thanks for making this, super cool