Public
Likeslimarmor
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v35View latest version
A lightweight, optimized vector database built on Val Town's SQLite (powered by Turso/libSQL) with Nebius Qwen3-Embedding-8B embeddings.
| Metric | Value |
|---|---|
| Embedding dimensions | 4096 |
| Storage per record | ~22 KB |
| Max records per 1GB | ~47,500 |
| Avg embedding time | ~460ms |
| Recommended maxDistance | 0.6 - 0.65 |
- Semantic search with cosine similarity + distance scores
- Smart re-embedding - only re-embeds when text changes
- Optimized index - 75% less storage with float8 compression
- Scale testing tools - seed data, calibrate thresholds, detailed stats
| Method | Endpoint | Description |
|---|---|---|
POST | /upsert | Insert/update {id, text, meta?} |
POST | /search | Search {query, k?, maxDistance?} |
POST | /delete | Delete {id} |
GET | /get?id=... | Get single record |
GET | /list?limit=... | List record IDs |
| Method | Endpoint | Description |
|---|---|---|
GET | /ping | Health check |
GET | /stats | Detailed storage stats |
GET | /seed?n=100 | Seed N synthetic records |
GET | /calibrate?q=... | Suggest distance thresholds |
POST | /reindex | Recreate optimized index |
POST | /clear?confirm=yes | Delete ALL records |
| Distance | Meaning | Action |
|---|---|---|
| 0.0 - 0.4 | Very similar | Always include |
| 0.4 - 0.6 | Related | Include (tight mode) |
| 0.6 - 0.7 | Somewhat related | Include (balanced mode) |
| 0.7+ | Likely unrelated | Filter out |
Default recommendation: maxDistance: 0.64
import * as db from "https://esm.town/v/kamenxrider/slimarmor/vectordb.ts";
await db.setup();
await db.upsert("doc-1", "Your text here", { category: "notes" });
const results = await db.search("search query", 10, 0.64);
| Variable | Description |
|---|---|
NEBIUS_API_KEY | Nebius API key for embeddings |
- Runtime: Val Town (Deno)
- Database: Val Town SQLite (Turso/libSQL with DiskANN)
- Embeddings: Nebius Qwen3-Embedding-8B (4096 dims)
- Index: Cosine similarity, max_neighbors=64, compress_neighbors=float8
MIT