vercel / modelfusion

The TypeScript library for building AI applications.
https://modelfusion.dev
MIT License
1.06k stars 76 forks source link

Implement sqlite-vss vector DB extension #158

Closed bjsi closed 8 months ago

bjsi commented 8 months ago

Just got started on the implementation, let me know if anything looks weird. Otherwise I'll keep going and test tomorrow!

Related issue: #157

vercel[bot] commented 8 months ago

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

Name Status Preview Comments Updated (UTC)
modelfusion ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 4, 2023 6:06pm
lgrammel commented 8 months ago

Just got started on the implementation, let me know if anything looks weird. Otherwise I'll keep going and test tomorrow!

Related issue: #157

looks good!

bjsi commented 8 months ago

@lgrammel

I did some testing. It seems to work. I ran into a bunch of typescript errors when trying to run the example examples/basic/src/vector-index/sqlite-vss-index-example.ts with ts-node. I think it's because I was trying to import from this library: https://alexgarcia.xyz/sqlite-vss/nodejs.html which contains the DLLs for the sqlite vector search extension. I think because it's ESM and and not commonjs? (I'm not so familiar with dealing with this). My solution was to just copy the platform and sqlite vss extension lib loading code with some minor changes int modelfusion because it's only 70 lines or so.

lgrammel commented 8 months ago

Hey @bjsi that looks great, can wait to try it out!

I have a few thoughts & questions:

  1. I prefer to seperate the setup code from the initialization code in general (happening as part of the constructor here). The reason is that in certain environment (cloud, production), the setup need to be very controlled and is handling in other ways (e.g. scripts), and I want to keep this consistent across the different ModelFusion integrations.

  2. If possible, I try to use versions of other tools that offer a REST interface and are spun up as a server. The reason is that it creates a separation of concerned and makes it easier to create scalable cloud deployments. Not sure if this is possible here and not having this is fine as a first version, but including libraries etc. usually leads to more issues down the road (different environments) compared to server integrations.

  3. Would you mind adding a docs page similar to https://modelfusion.dev/integration/vector-index/pinecone ? Then I could set it up on my machine and give it a try.

Thanks for the great contribution!

bjsi commented 8 months ago

seperate the setup code from the initialization code

Gotcha, I made the constructor take an initialised sqlite DB as a parameter instead.

I try to use versions of other tools that offer a REST interface and are spun up as a server

Not sure if this exists for SQLite. For me it's an advantage of SQLite that it's just a plain file on your hard drive. You're right about the library concerns though.

adding a docs page

Added 👍

lgrammel commented 8 months ago

Awesome, I'll test it more tomorrow and will tweak the docs a bit.

Meanwhile you can install it now: https://www.npmjs.com/package/@modelfusion/sqlite-vss

Thanks for your contribution!