Avatar

yawnxyz

i make ui for ai
Joined March 31, 2023
Public vals
86
yawnxyz avatar
yawnxyz
gettingOpenAiStreamingtoWork
HTTP
Blatantly copied code from theseephist's webgen: https://www.val.town/v/thesephist/webgen. Couldn't get streaming to work in valtown myself!!
0
yawnxyz avatar
yawnxyz
blurbs
HTTP
Blurbs Generator Give it a link (article, Science paper, or a PDF link), get a blurb and a bunch of tags. Built for Capsid & Tail but you can obviously use it for whatever
0
yawnxyz avatar
yawnxyz
buildclubProjectSearch
HTTP
Use embeddings / Lunr search on Airtable. Embeddings need to have been generated / stored on Airtable, or this gets very slow / costly. Simple usage: https://yawnxyz-buildclubprojectsearch.web.val.run/search?query=cars Full GET request: https://yawnxyz-buildclubprojectsearch.web.val.run/search?query=your+search+query&similarity_threshold=0.8&max_results=5&base_id=your_base_id&table_name=your_table_name&content_column=your_content_column&embedding_column=your_embedding_column
0
yawnxyz avatar
yawnxyz
dynamicFormInput
HTTP
An interactive, runnable TypeScript val by yawnxyz
0
yawnxyz avatar
yawnxyz
htmxCounterExample
HTTP
An interactive, runnable TypeScript val by yawnxyz
0
yawnxyz avatar
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
yawnxyz avatar
yawnxyz
embeddingsSearchExample
Script
This is an example of in-memory search, using a combination of lunr, OpenAI embeddings, and cosine similarity
0
yawnxyz avatar
yawnxyz
lunrSearchDemo
Script
A very simple demo of lunr, an in-memory text search that's perfect for Valtown
0
yawnxyz avatar
yawnxyz
aiImageExample
Script
// Function to handle image and text input using OpenAI's GPT-4-turbo
0
yawnxyz avatar
yawnxyz
aiBasicExample
Script
// basic text generation
0
yawnxyz avatar
yawnxyz
nighthawksChat
HTTP
It's Late. Get a drink. Have a chat. Welcome to Nighthawks. Nighthawks is an experiment in building interesting NPC characters with AI. The system combines large language models, simulates conversations using character sheets, and attempts to build memories based on the conversation. Improvise, have fun. Approach them like you would at a late night diner. Inspired by the Nighthawks painting. Built on a stripped down agent-based memory system.
0
yawnxyz avatar
yawnxyz
nighthawks
Script
This is nighthawks an experimental NPC character generator that remembers details about conversations. Import this into other workflows for now; a UI is coming soon!
0
yawnxyz avatar
yawnxyz
ai
HTTP
An http and class wrapper for Vercel's AI SDK Usage: Groq: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a beer joke"&provider=groq&model=llama3-8b-8192 Perplexity: https://yawnxyz-ai.web.val.run/generate?prompt="what's the latest phage directory capsid & tail article about?"&provider=perplexity Mistral: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a joke?"&provider=mistral&model="mistral-small-latest" async function calculateEmbeddings(text) { const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`; try { const response = await fetch(url); const data = await response.json(); return data; } catch (error) { console.error('Error calculating embeddings:', error); return null; } }
0
yawnxyz avatar
yawnxyz
openAiHelloWorld
Script
// Create a secret named OPENAI_API_KEY at https://www.val.town/settings/environment-variables
0
yawnxyz avatar
yawnxyz
stringCodeRunner
HTTP
Val.town somehow doesn't run multi-line code. Does work with "3+3" but not more complex stuff.
0
yawnxyz avatar
yawnxyz
honoJsxAlpineReactive
HTTP
Basic demo of getting reactive Alpine.js working on a hono/jsx "backend" For server <> frontend interaction, do form POST submissions (or potentially POST json to the public val address?) https://alpinejs.dev/start-here#building-a-counter
0