Public
Edited
Jun 7, 2023
6 forks
20 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
db = new DatasetteClient("https://sqlite-vss-example.fly.dev/headlines")
Insert cell
Insert cell
db
select rowid, headline, description, link, category, authors, date from articles limit 10;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
db
select
rowid,
headline,
hex(headline_embedding),
description,
hex(description_embedding)
from articles
limit 10;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
db
select rowid, distance
from vss_articles
where vss_search(
headline_embedding,
(select headline_embedding from articles where rowid = 590)
)
limit 20
Insert cell
Insert cell
db
with matches as (
select
rowid,
distance
from vss_articles
where vss_search(
headline_embedding,
(select headline_embedding from articles where rowid = 590)
)
limit 20
)
select
articles.rowid,
articles.headline,
matches.distance
from matches
left join articles on articles.rowid = matches.rowid
Insert cell
Insert cell
Insert cell
Insert cell
viewof query = Inputs.text({ submit: true, value: "global warm" })
Insert cell
queryHeadlines = db.sql`
with matches as (
select rowid, distance
from vss_articles
where vss_search(headline_embedding, st_encode(${query}))
limit 50
)
select articles.headline, matches.distance
from matches
left join articles on articles.rowid = matches.rowid
`
Insert cell
Inputs.table(queryHeadlines)
Insert cell
Insert cell
Insert cell
viewof query2 = Inputs.text({ submit: true, value: "scary orange holiday" })
Insert cell
queryDescriptions = db.sql`
with matches as (
select rowid, distance
from vss_articles
where vss_search(description_embedding, st_encode(${query2}))
limit 50
)
select articles.headline, description, matches.distance
from matches
left join articles on articles.rowid = matches.rowid
`
Insert cell
Inputs.table(queryDescriptions, { width: { headline: 350, description: 600 } })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { DatasetteClient } from "@ambassadors/datasette-client"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more