US Congress Stock Trading API examples & templates
Use these vals as a playground to view and fork US Congress Stock Trading API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.

yawnxyz
semanticSearch
Script
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();
0