Search

Results include substring matches and semantically similar vals. Learn more
substrate avatar
hackerNewsRAG
@substrate
Find comments on HN (powered by Algolia ), extract content and return a streaming markdown summary (powered by Substrate ). The RAG portion of this is 34 lines of Substrate code. Read the walkthrough: https://x.com/vprtwn/status/1812844236401762513 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits. See also: https://www.val.town/v/substrate/twitterRAG
HTTP (deprecated)
pi)), extract content and return a streaming markdown summary (powered by [Substrate](https://substrate.run)).
The RAG portion of this is 34 lines of Substrate code. Read the walkthrough: https://x.com/vprtwn/status/1812844236401762513
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits.
See also:
- https://www.val.town/v/substrate/twitterRAG
import { hnSearch } from "https://esm.town/v/stevekrouse/hnSearch";
import { ComputeJSON, ComputeText, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
import { zodToJsonSchema } from "npm:zod-to-json-schema";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
// search for HN comments using https://hn.algolia.com/api
markdown.id = "markdown";
const stream = await substrate.stream(markdown);
// Render streaming markdown
return new Response("User-agent: *\nDisallow: /");
const renderMarkdown = (await import("https://esm.town/v/substrate/renderMarkdown")).default;
return renderMarkdown(stream);
substrate avatar
imageGeneration
@substrate
Generate a description for an image, generate the image, and upscale it. 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generate a description for an image, generate the image, and upscale it.
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
import { ComputeText, GenerateImage, Substrate, UpscaleImage } from "npm:substrate";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const prompt = "futuristic city of atlants";
upscale.id = "upscale";
const stream = substrate.stream(upscale);
export default async function render(req: Request): Promise<Response> {
return new Response("User-agent: *\nDisallow: /");
const renderNodeResults = (await import("https://esm.town/v/substrate/renderNodeResults")).default;
return renderNodeResults(stream);
substrate avatar
intro
@substrate
Generate a story and summarize it using Substrate . 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits.
HTTP (deprecated)
Generate a story and summarize it using [Substrate](https://substrate.run/).
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits.
import { ComputeText, sb, Substrate } from "npm:substrate";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const story = new ComputeText({
max_tokens: 500,
const stream = await substrate.stream(summary);
export default async function render(req: Request): Promise<Response> {
return new Response("User-agent: *\nDisallow: /");
const renderNodeResults = (await import("https://esm.town/v/substrate/renderNodeResults")).default;
return renderNodeResults(stream);
substrate avatar
renderNodeResults
@substrate
Render streaming node results
HTTP (deprecated)
Render streaming node results
export default function renderNodeResults(stream: any) {
return new Response(
ReadableStream.from((async function*() {
// Yield the initial HTML structure with the persistent badge
yield new TextEncoder().encode(`
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
substrate avatar
renderMarkdown
@substrate
Render streaming markdown
HTTP (deprecated)
Render streaming markdown
export default function renderMarkdown(stream: any) {
let { readable, writable } = new TransformStream();
let writer = writable.getWriter();
const textEncoder = new TextEncoder();
writer.write(textEncoder.encode(`<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
substrate avatar
template
@substrate
Starter template for Substrate demos
HTTP (deprecated)
Starter template for Substrate demos
import promptHeader from "https://esm.town/v/substrate/promptHeader";
import { ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
export default async function handler(req: Request): Promise<Response> {
const prompt = new URL(req.url).searchParams.get("prompt") || "bullfrog";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const desc = new ComputeText({
const caption = new ComputeText({ prompt: "describe this", image_uris: [image.future.image_uri] });
const stream = await substrate.stream(caption);
async function* content() {
liam avatar
template
@liam
Starter template for Substrate demos
HTTP (deprecated)
Starter template for Substrate demos
import promptHeader from "https://esm.town/v/substrate/promptHeader";
import wrapper from "https://esm.town/v/substrate/substrateBadgeMiddleware";
import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
async function handler(req: Request): Promise<Response> {
const { prompt = "modernism" } = Object.fromEntries(searchParams);
// Substrate graph
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const startup_name = new ComputeText({
startup_name.future.text,
const stream = await substrate.stream(haiku);
async function* content() {
substrate avatar
illustratedPrimer
@substrate
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve". 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve".
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
import inputHeader from "https://esm.town/v/substrate/inputHeader";
import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
const input = new URL(req.url).searchParams.get("input") || "modernism";
// Substrate graph
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY_R") });
const Topic = z
const nodes = [image1, caption1, image2, caption2, image3, caption3, image4, caption4];
const stream = await substrate.stream(...nodes);
// UI
substrate avatar
shapeshift
@substrate
Semantically map a JSON object to a target schema using Substrate . 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits.
HTTP (deprecated)
Semantically map a JSON object to a target schema using [Substrate](https://substrate.run/).
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits.
import { ComputeJSON, ComputeText, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
city: "Anytown",
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const TargetSchema = z.object({
json_schema: zodToJsonSchema(TargetSchema),
const res = await substrate.run(json);
export default async function render(req: Request): Promise<Response> {
kousun12 avatar
IllustratedPrimer
@kousun12
Generates a streaming illustrated primer on a subject. ℹ️ Open the url and add a query parameter with a subject (click on titles to "delve"): https://substrate-illustratedprimer.web.val.run/?prompt=modernism 🪩 If you fork, you can sign up for Substrate to get your own API key and $50 in credits
HTTP (deprecated)
Generates a streaming illustrated primer on a subject.
dd a query parameter with a subject (click on titles to "delve"): https://substrate-illustratedprimer.web.val.run/?prompt=mo
🪩 If you fork, you can [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 in credits
import wrapper from "https://esm.town/v/substrate/substrateBadgeMiddleware";
import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
const { prompt = "modernism" } = Object.fromEntries(searchParams);
// Substrate graph
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const Topic = z
const nodes = [image1, caption1, image2, caption2, image3, caption3, image4, caption4];
const stream = await substrate.stream(...nodes);
// UI
substrate avatar
illustratedTopics
@substrate
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve". 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve".
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
import { zodToJsonSchema } from "npm:zod-to-json-schema";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY_R") });
const input = "astrobiology"
const nodes = [image1, caption1, image2, caption2, image3, caption3, image4, caption4];
const stream = await substrate.stream(...nodes);
// Render UI
substrate avatar
spanishVocabLesson
@substrate
Generates spanish flashcards on a topic, including generated images and speech. 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates spanish flashcards on a topic, including generated images and speech.
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
import { ComputeJSON, ComputeText, GenerateImage, GenerateSpeech, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
const input = "scuba diving";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const vocabLesson = z.object({
model: "Llama3Instruct70B",
const stream = await substrate.stream(html);
// Render UI
return new Response("User-agent: *\nDisallow: /");
const renderHTML = (await import("https://esm.town/v/substrate/renderHTML")).default;
return renderHTML(stream);
nknj avatar
illustratedPrimer
@nknj
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve". 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve".
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
import inputHeader from "https://esm.town/v/substrate/inputHeader";
import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
const input = new URL(req.url).searchParams.get("input") || "modernism";
// Substrate graph
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY_R") });
const Topic = z
const nodes = [image1, caption1, image2, caption2, image3, caption3, image4, caption4];
const stream = await substrate.stream(...nodes);
// UI
yawnxyz avatar
illustratedPrimer
@yawnxyz
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve". 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve".
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
import inputHeader from "https://esm.town/v/substrate/inputHeader";
import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
import { z } from "npm:zod";
const input = new URL(req.url).searchParams.get("input") || "modernism";
// Substrate graph
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY_R") });
const Topic = z
const nodes = [image1, caption1, image2, caption2, image3, caption3, image4, caption4];
const stream = await substrate.stream(...nodes);
// UI
substrate avatar
inputHeader
@substrate
An interactive, runnable TypeScript val by substrate
HTTP (deprecated)
</div>
<div style="text-align:right;background-color:#000;padding:4px;border-radius:4px;">
<a href="https://www.substrate.run" target="_blank" style="font-size:0.8rem;color:#fff;text-decoration:none;display:block
<a href="#" onclick="window.open(getSourceUrl(), '_blank')" style="font-size:0.8rem;color:#fff;text-decoration:none;displ
</div>