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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more