10const { owner, name } = extractValInfo(import.meta.url);
1112export default async function(req: Request): Promise<Response> {
13const url = new URL(req.url);
14const model = url.searchParams.get('model') || 'gpt-4o';
14};
1516async function getResults(q: string, n: number): Promise<ShotResult[]> {
17const substrate = new Substrate({
18apiKey: process.env.SUBSTRATE_API_KEY,
GetWebsiteMetadatamain.tsx3 matches
2import getOpengraphMetadata from "https://esm.town/v/dvsj/getOpengraphMetadata";
34export default async function(req: Request): Promise<Response> {
5// First extract query param from the URL
6const url = new URL(req.url);
27return Response.json({
28"error":
29"targetURL is missing in query params. If you want to get the metadata for `https://dvsj.in`, call this function in this format: `https://fn-url?targetURL=https://dvsj.in`",
30});
31}
33return Response.json({
34"error":
35"Did you forget to add the magic word 'https://''?. If you want to get the metadata for `https://dvsj.in`, call this function in this format: `https://fn-url?targetURL=https://dvsj.in`",
36});
37}
15import { renderToString } from "npm:react-dom/server";
1617export default function(
18{ tempValsParentFolderId, username }: { tempValsParentFolderId: string; username: string },
19) {
35the simplest way to achieve the goal, though you can add some inline comments to explain your
36reasoning (not for every line, but for major groups of lines). Don't use any environment variables
37unless strictly necessary, for example use APIs that don't require a key, prefer internal function
38imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
39functions where possible. Unless specified, don't add error handling,
40make sure that errors bubble up to the caller.
41Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
48\`\`\`
49There should be no comments like "more content here", it should be complete and directly runnable.
50The val should create a "export default async function main" which is the main function that gets
51executed on every HTTP request.
52`.replace("\n", " ");
5354// Your response should start with \`\`\`ts and end with \`\`\`.
55// The val should create a "export default async function main() {" which
56// is the main function that gets executed, without any arguments. Don't return a Response object,
57// just return a plain Javascript object, array, or string.
5895const writer = writable.getWriter();
96const textEncoder = new TextEncoder();
97function write(text) {
98writer.write(textEncoder.encode(text));
99}
173</div>
174<script>
175function updateValName(valName) {
176const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
177const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
181document.getElementById('open-link').href = previewUrl;
182}
183function saveVal() {
184if (window.codeMirrorEditor) {
185document.getElementById("save-icon").classList.remove("hidden");
201return false;
202})
203function openTab(tab) {
204const tabButtonCode = document.getElementById("tab-button-code");
205const tabButtonPreview = document.getElementById("tab-button-preview");
221}
222}
223function toggleTab() {
224openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
225}
280(() => {
281const scrollingElement = document.getElementById("conversation-container");
282const callback = function (mutationsList, observer) {
283scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
284};
398window.setCodeMirrorContent({ doc: '', old: ''});
399let fullStr = "";
400window.addToken = function(str) {
401fullStr += str;
402const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "").replace(/^ts\\n/, '');
437},
438);
439(async function() {
440try {
441await sleep(300);
loadPythonmain.tsx6 matches
7(globalThis as any).navigator = {};
89// Function to load Pyodide and Python packages
10export async function loadPython(params?: { packages: string[] }) {
11const pyodide = await pyodideModule.loadPyodide();
12for (const pkg of params?.packages || []) {
14}
1516// Returns a function that can run Python code asynchronously
17return (strings: TemplateStringsArray) => pyodide.runPythonAsync(strings[0]);
18}
1920// Function to run Python code
21async function runHelloWorld() {
22const runPython = await loadPython();
23// Run a simple Python print statement
25}
2627// Execute the function
28runHelloWorld().catch(console.error);
glideImportDemomain.tsx2 matches
1// 1. Start by importing the Glide helper library.
2//
3// Soon, this functionality will be part of the official
4// @glideapps/tables npm package.
5import * as Glide from "https://esm.town/v/dvdsgl/glide?v=661";
18// For example, you could call an API in a loop, using yield for each
19// batch of rows to import.
20async function* getRows() {
21// Yield rows to import them:
22yield { name: "David", favoriteTool: "Glide" };
21export const layer = (info: GlideInfo) => Layer.succeed(Glide, Glide.of(info));
2223const getGlide: Effect.Effect<GlideInfo, GlideError> = Effect.gen(function*() {
24const provided = yield* Effect.serviceOption(Glide);
2537});
3839function removeUnsupportedColumnTypes(row: any): any {
40const pr = { ...row };
41for (const [k, v] of Object.entries(pr)) {
4950// Handles calling fetch, checking for API errors
51function fetchGlide<A>(
52method: "GET" | "POST" | "PUT",
53url: string,
54body: unknown,
55): Effect.Effect<A, GlideError> {
56return Effect.gen(function*() {
57const { token } = yield* getGlide;
58const result = yield* Effect.tryPromise(() =>
90rows: Stash | any[],
91): Effect.Effect<PutResult, GlideError> =>
92Effect.gen(function*() {
93// Some tables have a prefix, e.g. "native-table-" but this API
94// does not accept it.
118serial: string | number,
119): Effect.Effect<Stash, GlideError> =>
120Effect.gen(function*() {
121const id = typeof stash === "string" ? stash : stash.$stashID;
122136};
137138async function* bufferAsyncIterable<T>(
139asyncIterable: AsyncIterable<T | T[]>,
140max = 1_000,
152}
153154export function importTableEffect<Row>(props: Import<Row>) {
155const { table, getRows } = props;
156157return Effect.gen(function*() {
158yield* Effect.logDebug(`ingest start`);
159170let serial = 0;
171yield* Stream.runForEach(stream, (rows) =>
172Effect.gen(function*() {
173totalRows += rows.length;
174yield* Effect.logDebug(`ingest ${totalRows} total rows`);
181182// Runs an injestion job.
183export async function importTable<Row>(
184props: Import<Row> & { debug?: boolean },
185) {
azureCheetahmain.tsx14 matches
16import { renderToString } from "npm:react-dom/server";
1718export default function(
19{ tempValsParentFolderId }: { tempValsParentFolderId: string },
20) {
38the simplest way to achieve the goal, though you can add some inline comments to explain your
39reasoning (not for every line, but for major groups of lines). Don't use any environment variables
40unless strictly necessary, for example use APIs that don't require a key, prefer internal function
41imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
42functions where possible. Unless specified, don't add error handling,
43make sure that errors bubble up to the caller.
44Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
51\`\`\`
52There should be no comments like "more content here", it should be complete and directly runnable.
53The val should create a "export default async function main" which is the main function that gets
54executed on every HTTP request.
55`.replace("\n", " ");
5657// Your response should start with \`\`\`ts and end with \`\`\`.
58// The val should create a "export default async function main() {" which
59// is the main function that gets executed, without any arguments. Don't return a Response object,
60// just return a plain Javascript object, array, or string.
6198const writer = writable.getWriter();
99const textEncoder = new TextEncoder();
100function write(text) {
101writer.write(textEncoder.encode(text));
102}
174</div>
175<script>
176function updateValName(valName) {
177const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
178const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
182document.getElementById('open-link').href = previewUrl;
183}
184function saveVal() {
185if (window.codeMirrorEditor) {
186document.getElementById("save-icon").classList.remove("hidden");
202return false;
203})
204function openTab(tab) {
205const tabButtonCode = document.getElementById("tab-button-code");
206const tabButtonPreview = document.getElementById("tab-button-preview");
222}
223}
224function toggleTab() {
225openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
226}
281(() => {
282const scrollingElement = document.getElementById("conversation-container");
283const callback = function (mutationsList, observer) {
284scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
285};
390window.setCodeMirrorContent({ doc: '', old: ''});
391let fullStr = "";
392window.addToken = function(str) {
393fullStr += str;
394const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "").replace(/^ts\\n/, '');
429},
430);
431(async function() {
432try {
433await sleep(300);
16import { renderToString } from "npm:react-dom/server";
1718export default function(
19{ tempValsParentFolderId }: { tempValsParentFolderId: string },
20) {
38the simplest way to achieve the goal, though you can add some inline comments to explain your
39reasoning (not for every line, but for major groups of lines). Don't use any environment variables
40unless strictly necessary, for example use APIs that don't require a key, prefer internal function
41imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
42functions where possible. Unless specified, don't add error handling,
43make sure that errors bubble up to the caller.
44Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
51\`\`\`
52There should be no comments like "more content here", it should be complete and directly runnable.
53The val should create a "export default async function main" which is the main function that gets
54executed on every HTTP request.
55`.replace("\n", " ");
5657// Your response should start with \`\`\`ts and end with \`\`\`.
58// The val should create a "export default async function main() {" which
59// is the main function that gets executed, without any arguments. Don't return a Response object,
60// just return a plain Javascript object, array, or string.
6198const writer = writable.getWriter();
99const textEncoder = new TextEncoder();
100function write(text) {
101writer.write(textEncoder.encode(text));
102}
174</div>
175<script>
176function updateValName(valName) {
177const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
178const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
182document.getElementById('open-link').href = previewUrl;
183}
184function saveVal() {
185if (window.codeMirrorEditor) {
186document.getElementById("save-icon").classList.remove("hidden");
202return false;
203})
204function openTab(tab) {
205const tabButtonCode = document.getElementById("tab-button-code");
206const tabButtonPreview = document.getElementById("tab-button-preview");
222}
223}
224function toggleTab() {
225openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
226}
281(() => {
282const scrollingElement = document.getElementById("conversation-container");
283const callback = function (mutationsList, observer) {
284scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
285};
390window.setCodeMirrorContent({ doc: '', old: ''});
391let fullStr = "";
392window.addToken = function(str) {
393fullStr += str;
394const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "").replace(/^ts\\n/, '');
429},
430);
431(async function() {
432try {
433await sleep(300);
22The first timestamp should be 0.`;
2324async function processAudio(audio_uri) {
25const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
26const opts = { cache_age: 60 * 60 * 24 * 7 };
9192// Render site
93export default async function(req: Request): Promise<Response> {
94const url = new URL(req.url);
95const audio_uri = url.searchParams.get("url");
400let currentChapterIndex = 0;
401402function updateText() {
403const currentTime = audioPlayer.currentTime;
404let segmentToDisplay = null;
515const updateInterval = 1000 / 40;
516517function updateLoop(timestamp) {
518if (timestamp - lastUpdateTime > updateInterval) {
519updateText();