1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { ComputeText, sb, Substrate } from "npm:substrate";
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const story = new ComputeText({
prompt: "tell me a story, be concise",
max_tokens: 500,
});
const summary = new ComputeText({
prompt: sb.interpolate`summarize this story in one sentence. do not preface the summary: ${story.future.text}`,
max_tokens: 500,
});
const stream = await substrate.stream(summary);
export default async function render(req: Request): Promise<Response> {
if (new URL(req.url).pathname === "/robots.txt") {
return new Response("User-agent: *\nDisallow: /");
}
const renderNodeResults = (await import("https://esm.town/v/substrate/renderNodeResults")).default;
return renderNodeResults(stream);
}