valleBlogV0main.tsx1 match
38model: openai("gpt-4o", {
39baseURL: "https://std-openaiproxy.web.val.run/v1",
40apiKey: Deno.env.get("valtown"),
41} as any),
42messages: [
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
1112<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>
94if (!inputs.$key || inputs.$key != Deno.env.get("BB_SERVICE_KEY")) {
95return {
96$error: "Must provide an API key to access the service.",
97};
98}
sweetAzureFinchmain.tsx4 matches
23export default async function saveToAirtable(videoName, videoDescription, videoCover, videoFile, clientLogo) {
4// Set up your Airtable API key and base ID
5const API_KEY = "patrq3goiFF1u09Dz.b435affff5fb534b9d5c76e2544ddf88612d6a19aebaec5c14f9434b0d10d2e6";
6const BASE_ID = "appoxM2jYcSNhc5OX";
7const TABLE_NAME = "videos_from_ssa";
89// Initialize Airtable with your API key
10Airtable.configure({ apiKey: API_KEY });
11const base = Airtable.base(BASE_ID);
12
reloadOnSaveREADME.md1 match
1# Live reload in new tabs
23When you're working on an HTML HTTP val in a new tab, it's annoying to have to manually reload the tab on every save. In the Val Town editor, you can hit cmd+enter, but there's nothing like that for a val in a new tab because Val Town doesn't control that new tab (like we control the iframe in the browser preview). However, you control that HTML via the fetch handler you're writing, so you can add a script that polls the Val Town API for the current version number of your val, and reload itself if it detects a new version. This val has a collection of helpers to help you do just that.
45## Usage
linkInBioTemplatemain.tsx1 match
174<title>Side School Seminar</title>
175<meta name="viewport" content="width=device-width, initial-scale=1">
176<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
177<style>${css}</style>
178</head>
weeksummarymain.tsx3 matches
37prev => [...prev, `Fetching scraps and generating summary for week of ${weekStart.toDateString()}...`],
38);
39const response = await fetch(`/api/summary?week=${weekStart.toISOString()}`);
40const data = await response.json();
41120<footer className="mt-8 text-center text-sm">
121<h3>curl</h3>
122<pre class="bg-black text-white text-sm font-mono">curl 'https://ejfox-weeksummary.web.val.run/api/summary?week=2024-06-16T00:00:00.000Z'</pre>
123
124<a
146const url = new URL(request.url);
147148if (url.pathname === "/api/summary") {
149const { OpenAI } = await import("https://esm.town/v/std/openai");
150const openai = new OpenAI();
211Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
212Start your response with a comment explaining how your approach will work, what libraries or
213API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
214the simplest way to achieve the goal, though you can add some inline comments to explain your
215reasoning (not for every line, but for major groups of lines). Don't use any environment variables
216unless strictly necessary, for example use APIs that don't require a key, prefer internal function
217imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
218functions where possible. Unless specified, don't add error handling,
219make sure that errors bubble up to the caller.
220Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221not practical for the user's request (e.g. if they ask for a particular animated gif).
222If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
223explicitly specified otherwise. Use the current val name for the storage key, which you can get
224using the "pomdtr/extractValInfo" val, which you can call like this:
273Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
274Add comments at the top of the file explaining how your approach works, what libraries or
275API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
276the simplest way to achieve the goal, though you can add some inline comments to explain your
277reasoning (not for every line, but for major groups of lines). Don't use any environment variables
278unless strictly necessary, for example use APIs that don't require a key, prefer internal function
279imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
285explicitly specified otherwise. Use the current val name for the storage key, which you can get
286using the "pomdtr/extractValInfo" val, which you can call like this:
389\`\`\`
390
391### Lower-level API
392
393We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
394
395- \`async get(key: string)\`: Retrieves a blob for a given key.
396- \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
397
398### Limitations
12041205const tempValName = `valle_tmp_${Math.random() * 10}`.replaceAll(".", "");
1206// Errors in running the val bubble up through this API, so ignore them.
1207await vt.vals.create({ name: tempValName, code: newCode, type: "http" as any, privacy: "unlisted" }).catch(
1208(error) => {
slackScoutREADME.md4 matches
7## Getting Started
8To run Slack Scout, you’ll need a
9- Browserbase API key
10- Slack Webhook URL: setup [here](https://docs.val.town/integrations/slack/send-messages-to-slack/)
11- Twitter Developer API key
1213### Browserbase
192021We’ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. _If you decide to use Browserbase, we can lend our token. Comment below for access._
2223Once you have the `SLACK_WEBHOOK_URL`, `BROWSERBASE_API_KEY`, and `TWITTER_BEARER_TOKEN`, input all of these as [Val Town Environment Variables](https://www.val.town/settings/environment-variables).
2425---
githubGistsmain.tsx1 match
3// GitHub gists
4export let githubGists = fetchJSON(
5"https://api.github.com/users/stevekrouse/gists",
6);
7