Public
Back
Version 2
7/25/2024
export default async function getValsContextWindow(model: any) {
const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
const API_URL = "https://api.val.town";
const sections = [
{
name: "Imports",
templates: [
{
name: "Import from NPM",
prompt: "Write a val that imports lodash and generates a range of numbers",
code: `import _ from "npm:lodash-es";
let numbers = _.range(10);
console.log(numbers.map(n => n * 2));`,
},
{
prompt: "Write a val that imports from another val and gets the weather",
code: `import { getWeather } from "https://esm.town/v/stevekrouse/getWeather";
let weather = await getWeather("Brooklyn, NY");
console.log(weather.current_condition[0].FeelsLikeF)`,
},
],
},
{
name: "Server-Rendered JSX",
templates: [
{
type: "http",
prompt: "Generate a val that uses React to render HTML",
code: `/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export const reactExample = (request: Request) =>
stevekrouse-vallegetvalscontextwindow.web.val.run
Updated: July 25, 2024