This is a example application showcasing a recommendation system for blogs.
Please check the repo's README for prerequisites for running this example.
This sample uses the Vector extension to sqlite, which is available with Turso.
- Create a Turso database using personal account and get configs
turso db create --enable-extensions
# Get the url
turso db show <db-name>
# Create access token
turso db tokens create <db-name> --expiration none
-
make a copy of
runtime-config-template.toml
asruntime-config.toml
and fill in the details -
Shell into Turso Db to create virtual table using the
vss
module
$ turso db shell <db-name>
- CREATE virtual TABLE vss_blog_posts USING vss0(embedding(384));
$ npm install
$ spin build -u --runtime-config-file runtime-config.toml --sqlite @migrations.sql
Note: If you are using the Cloud GPU component, remember to add the
[llm_compute]
section to theruntime-config.toml
file.
- Create embeddings for all the posts
./update_embeddings.sh http://localhost:3000
- Query for similar articles
curl -X POST -d '{"blogPath": "scale-to-zero-problem"}' http://localhost:3000/getRecommendations
$ spin deploy