Skip to content

Conversation

@himself65
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: f62336c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Sep 24, 2024

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

Name Status Preview Comments Updated (UTC)
llama-index-ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 1:43am

Copy link
Contributor Author

@himself65 himself65 left a comment

Choose a reason for hiding this comment

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

forward to some our previous contributors see if like/dislike this change

/cc @gorango @AndreMaz

@@ -0,0 +1,13 @@
/**
* should compatible with npm:pg and npm:postgres
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in the future, there could have sqlite vector store, so type should also comptatable with node:sqlite sqlite3 better-sqlite3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 24, 2024

Open in Stackblitz

@llamaindex/autotool

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/autotool@1248

@llamaindex/cloud

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/cloud@1248

@llamaindex/community

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/community@1248

@llamaindex/core

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/core@1248

@llamaindex/env

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/env@1248

llamaindex

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/llamaindex@1248

@llamaindex/experimental

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/experimental@1248

@llamaindex/wasm-tools

pnpm add https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/wasm-tools@1248

commit: f62336c

@AndreMaz
Copy link
Contributor

AndreMaz commented Sep 25, 2024

This is just personal preference but I would do things in a slightly different way.

Instead of function fromPostgres() and function fromPG() I would create a dir called adapters at src/vector-store and then create a base.ts adapter with the connect(), disconnect(), query() and etc. methods.

Then I would create the pg.ts that would extend the base.ts and implement the logic in there. Same for the postgres and other clients.

After this the PGVectorStore would have a reference to the adapter instance and then call it as needed.

I would also export the base.ts to allow the user to create their own version of adapter (node:sqlite, sqlite3, better-sqlite3 or any other) and pass it as a param to a PGVectorStore's constructor(). Essentially the user would be allowed to pass a custom adapter to the vector-store (as long as it correctly implements the methods of base.ts)

@himself65 what I said above is just a suggestion that I think will be easier to maintain in the long run. Other than that your PR looks good 👍

@himself65 himself65 marked this pull request as ready for review September 25, 2024 22:51
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.

2 participants