8382 |
Building search-based RAG using Claude, Datasette and Val Town |
// The SQL query from earlier
const sql = `select
blog_entry.id,
blog_entry.title,
blog_entry.body,
blog_entry.created
from
blog_entry
join blog_entry_fts on blog_entry_fts.rowid = blog_entry.rowid
where
blog_entry_fts match :search
order by
rank
limit
10`;
async function runSearch(keywords) {
// Turn the keywords into "word1" OR "word2" OR "word3"
const search = keywords.map(s => `"${s}"`).join(" OR ");
// Compose the JSON API URL to run the query
const params = new URLSearchParams({
search,
sql,
_shape: "array",
});
const url = "https://datasette.simonwillison.net/simonwillisonblog.json?" + params;
const result = await (await fetch(url)).json();
return result;
} |
https://simonwillison.net/e/8382 |
8382 |
Building search-based RAG using Claude, Datasette and Val Town |
select
blog_entry.id,
blog_entry.title,
blog_entry.body,
blog_entry.created
from
blog_entry
join blog_entry_fts on blog_entry_fts.rowid = blog_entry.rowid
where
blog_entry_fts match :search
order by
rank
limit
10 |
https://simonwillison.net/e/8382 |
8380 |
Language models on the command-line |
llm embed-multi links \
-d simonwillisonblog.db \
--sql 'select id, link_url, link_title, commentary from blog_blogmark' \
-m 3-small --store
|
https://simonwillison.net/e/8380 |
8380 |
Language models on the command-line |
select id, link_url, link_title, commentary from blog_blogmark
|
https://simonwillison.net/e/8380 |
8327 |
Interesting ideas in Observable Framework |
```js echo
const packageName = view(Inputs.select(packages, {
value: "sqlite-utils",
label: "Package"
}));
``` |
https://simonwillison.net/e/8327 |
8327 |
Interesting ideas in Observable Framework |
```js echo
const packages_sql = "select package from stats group by package order by max(downloads) desc"
```
```js echo
const packages = fetch(
`https://datasette.io/content.json?sql=${encodeURIComponent(
packages_sql
)}&_size=max&_shape=arrayfirst`
).then((r) => r.json());
``` |
https://simonwillison.net/e/8327 |
8326 |
Weeknotes: Getting ready for NICAR |
dclient query https://datasette.io/content \
"select * from news limit 3" |
https://simonwillison.net/e/8326 |
8296 |
Embeddings: What they are and why they matter |
select id, hex(embedding) from embeddings |
https://simonwillison.net/e/8296 |
8296 |
Embeddings: What they are and why they matter |
select id, llm_embed_decode(embedding) from embeddings limit 10 |
https://simonwillison.net/e/8296 |
8296 |
Embeddings: What they are and why they matter |
select
id,
llm_embed_cosine(
embedding,
(
select
embedding
from
embeddings
where
id = 'sqlite_sqlite-tg.md'
)
) as score
from
embeddings
order by
score desc
limit 5 |
https://simonwillison.net/e/8296 |