FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
yawnxyz
yawnxyzsemanticSearch
Public
Like
semanticSearch
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/2/2024
README.md

In-memory semantic search; load it up with valtown KV.

This is a "dumb" version of vector search, for prototyping RAG responses and UIs — with both regular search (w/ Lunr) and vector search (with OpenAI embeddings + cosine similarity)

Usage:

import { semanticSearch } from "https://esm.town/v/yawnxyz/semanticSearch";

const documents = [
  { id: 1, content: 'cats dogs' },
  { id: 2, content: 'elephants giraffes lions tigers' },
  { id: 3, content: 'edam camembert cheddar' }
];

async function runExample() {
  // Add documents to the semantic search instance
  await semanticSearch.addDocuments(documents);

  const results = await semanticSearch.search('animals', 0, 3);
  console.log('Top 3 search results for "animals":');
  console.log(results);
}

runExample();

Migrated from folder: Libraries/SemanticSearch/semanticSearch

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesCLIAI agentsCode intelligenceSlack integrationsGTMPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.