4const cacheBlobKey = "getValsContextWindowCache3";
5
6export default async function getValsContextWindow(model: any) {
7 const fullCacheBlobKey = `${cacheBlobKey}-${model}`;
8 const cached = await blob.getJSON(fullCacheBlobKey);
194 import { render } from "npm:preact-render-to-string";
195
196 export default async function(req: Request) {
197 return new Response(
198 render(
223 const FLAT_TEMPLATES = sections.flatMap((section) => section.templates);
224
225 function tsResponse(code) {
226 return "```ts\n" + code + "\n```";
227 }
394 ### Utilities
395
396 Our Blob SDK also includes some utility functions to make working with blobs easier.
397
398 ##### Copy
432 role: "assistant",
433 content:
434 "\n```ts\nexport default async function (req: Request): Promise<Response> {\n return Response.json(\"Hello world\")\n}\n```",
435 },
436 {
441 role: "assistant",
442 content:
443 "\n```ts\nexport default async function(req: Request): Promise<Response> {\n const query = new URL(req.url).searchParams;\n\n // Read name from the querystring or body. Defaults to \"you\" if not present.\n const name = query.get(\"name\") || (await req.json().catch(() => ({}))).name || \"you\";\n\n // Returns the HTML response\n return new Response(`<h1>Hi ${name}!</h1>`, {\n headers: { \"Content-Type\": \"text/html\" },\n });\n}\n```",
444 },
445 {
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m¤t_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {
8import _ from "npm:lodash@4";
9
10async function main(req: Request): Promise<Response> {
11 const { readable, writable } = new TransformStream();
12 const writer = writable.getWriter();
20 <script>
21 // Scroll to the bottom of the page when the page changes.
22 (new MutationObserver(function (mutationsList, observer) {
23 window.scrollTo({ left: 0, top: document.body.scrollHeight, behavior: "instant" });
24 })).observe(document, { childList: true, characterData: true, subtree: true });
47 Your response should start with \`\`\`ts and end with \`\`\`, so full code fences.
48 There should be no comments like "more content here", it should be complete and directly runnable.
49 The val should have an "export default async function main". The val should return a valid HTML website.
50 Prefer using Tailwind. Put frontend functions in a <script> tag, using dangerouslySetInnerHTML. Don't use Hono. Don't use Response.redirect.
51 `.replace("\n", " "),
52 },
136
137export const service = (boardUrl: string, options?: ServiceOptions) => {
138 return async function(req: Request): Promise<Response> {
139 const url = new URL(req.url);
140 const path = url.pathname;
1const Airtable = require("airtable");
2
3export default async function saveToAirtable(videoName, videoDescription, videoCover, videoFile, clientLogo) {
4 // Set up your Airtable API key and base ID
5 const API_KEY = "patrq3goiFF1u09Dz.b435affff5fb534b9d5c76e2544ddf88612d6a19aebaec5c14f9434b0d10d2e6";
26}
27
28function App({ requests, stats, fullRequest }: { requests: RequestData[], stats: Stats, fullRequest?: RequestData }) {
29 return (
30 <div>
84}
85
86export default async function server(request: Request): Promise<Response> {
87 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
88 const SCHEMA_VERSION = 1;
9import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
10
11export default reloadOnSaveFetchMiddleware(async function(req: Request): Promise<Response> {
12 return html(`<h1>Hello!!</h1>`);
13})
8
9// this script runs client-side
10export const reloadOnVals = async function(vals: ValRef[]) {
11 const valVersions = await Promise.all(vals.map(getCurrentValVersionNumber));
12 // console.log("initialValVersions: ", valVersions);
22
23// experimental - don't use this
24export function reloadOnSaveHonoMiddleware(vals: ValRef[] = [rootValRef()]): MiddlewareHandler {
25 return async function(c, next) {
26 await next();
27 // don't reload on custom domains, only reload on val.run URLs
40 * @param vals to watch
41 */
42export function reloadOnSaveFetchMiddleware(
43 handler: (req: Request) => Response | Promise<Response>,
44 vals = [rootValRef()],
18];
19
20function App() {
21 const [votes, setVotes] = useState({});
22 const [selectedLocation, setSelectedLocation] = useState(null);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
106}
107
108async function server(request: Request): Promise<Response> {
109 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
110 const SCHEMA_VERSION = 1;
9import { OpenAI } from "https://esm.town/v/std/openai";
10
11export default async function server(request: Request): Promise<Response> {
12 const url = new URL(request.url);
13 const code = url.searchParams.get("code") || "console.log(\"Hello, World!\");";
75 hljs.highlightAll();
76
77 function shuffleGradient() {
78 const t1 = Math.random();
79 const t2 = (t1 + 0.3) % 1; // Ensure colors are distinct
91 const duration = 10000; // 10 seconds
92
93 function animate(timestamp) {
94 if (!start) start = timestamp;
95 const progress = (timestamp - start) / duration;
12}
13
14function App() {
15 const [summary, setSummary] = useState<string>("");
16 const [loading, setLoading] = useState<boolean>(true);
135}
136
137function client() {
138 createRoot(document.getElementById("root")).render(<App />);
139}
143}
144
145async function server(request: Request): Promise<Response> {
146 const url = new URL(request.url);
147