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

feat(community): Add delete and allow default row id in libsql #7053

Merged
merged 5 commits into from
Oct 29, 2024

Conversation

cdierkens
Copy link
Contributor

@cdierkens cdierkens commented Oct 24, 2024

@jacoblee93 Sorry to tag directly, just noticed you were working here last!

Changes

  • used named parameters throughout
  • in the addVectors function we've used the vector(:embedding) libsql function
  • returned every row id on insert
  • ensure that we return a String wherever id's are returned per the Document type
  • implemented the delete all and delete function
  • allow creating and searching from table with an implicit ROWID column

Could use Help

I'd suspect that we should use OpenAIEmbeddings throughout so we can run all tests against a local libsql db and a remote hosted db. Right now I used OllamaEmbeddings in all the new test because the OPENAI_API_KEY in my .env was not picked up. OllamaEmbeddings with the default model are 1024 dimensions while OpenAIEmbeddings are 1536. I don't see a create table statement in the existing test, so I'm not sure if it was created manually with 1536, or that's something that Turso does automatically.

Other things I wouldn't mind adding

  • filtering (can just replicate exact and in matches like other sql adapters)
  • specifying the index in the constructor with a default

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 24, 2024
Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Oct 29, 2024 8:33pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Oct 29, 2024 8:33pm

@dosubot dosubot bot added the auto:improvement Medium size change to existing code to handle new use-cases label Oct 24, 2024
@cdierkens
Copy link
Contributor Author

Also, let me know if I should create issues to go along with this PR.

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Oct 24, 2024

Hey @cdierkens! Issue would be nice but not necessary.

I was going off the setup instructions here:

https://js.langchain.com/docs/integrations/vectorstores/libsql/#setup-the-table-and-index

Had to manually set up a Turso instance for integration tests.

Thanks for this! Will look hopefully tomorrow!

@cdierkens
Copy link
Contributor Author

I was going off the setup instructions here:

@jacoblee93 Yeah I had issues with those instructions as well. Following these helped alot:
https://docs.turso.tech/features/ai-and-embeddings

@jacoblee93
Copy link
Collaborator

Oh I updated them in my previous PR and they should work now!

@cdierkens
Copy link
Contributor Author

@jacoblee93 What can I do to keep this moving. I'm available to help in any way.

@jacoblee93
Copy link
Collaborator

You're good, will look today or tomorrow!

@jacoblee93 jacoblee93 changed the title Add delete and allow default row id in libsql feat(community): Add delete and allow default row id in libsql Oct 29, 2024
*/
async delete(params: { ids?: string[] | number[] }): Promise<void> {
if (!params.ids) {
await this.db.execute(`DELETE FROM ${this.table}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We usually gate this on a deleteAll flag - will add

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

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

Thank you for your patience!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Oct 29, 2024
@cdierkens
Copy link
Contributor Author

Thank you for your patience!

No worries!

@jacoblee93 jacoblee93 merged commit e53531a into langchain-ai:main Oct 29, 2024
31 checks passed
FilipZmijewski pushed a commit to FilipZmijewski/langchainjs that referenced this pull request Oct 31, 2024
aditishree1 pushed a commit to aditishree1/langchainjs that referenced this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases lgtm PRs that are ready to be merged as-is size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants