71# Long-term memory
72
73At some point the user might ask you to do something with "memory". Things like "remember", "save to memory", "forget", "update memory", etc. Please use corresponding actions to achieve those tasks. User might also ask you to perform some task with the context of your "memory" - in that case fetch all memories before proceeding with the task. The memories should be formed in a clear and purely informative language, void of unnecessary adjectives or decorative language forms. An exception to that rule might be a case when the language itself is the integral part of information (snippet of writing to remember for later, examples of some specific language forms, quotes, etc.).
74
75Structure of a memory:
1export default async function fetchNewPublicGitHubRepos() {
2 // Generate today's date in YYYY-MM-DD format
3 const today = new Date().toISOString().split("T")[0];
9 const url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&order=${order}`;
10
11 const response = await fetch(url, {
12 headers: {
13 "Accept": "application/vnd.github.v3+json",
14 "User-Agent": "Deno-GitHub-Repo-Fetcher", // GitHub API requires a user-agent header
15 },
16 });
246 const formData = new FormData();
247 formData.append("audio", blob, "recording.wav");
248 const response = await fetch("/transcribe", { method: "POST", body: formData });
249 if (response.ok) {
250 const result = await response.text();
286 const language2Value = document.getElementById("language2").value;
287
288 const response = await fetch("/translate", {
289 method: "POST",
290 headers: { "Content-Type": "application/json" },
328
329 if (text && voice) {
330 const response = await fetch('/generate-speech', {
331 method: 'POST',
332 headers: { 'Content-Type': 'application/json' },
455});
456
457export default app.fetch;
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
10 image,
11 );
12 const data = await (await fetch(await getUploadURL(), {
13 "body": fd,
14 "method": "POST",
24}
25async function getUploadURL(): Promise<string> {
26 const data = await (await fetch("https://www.val.town/api/trpc/generateImageUploadUrl", {
27 "headers": {
28 "content-type": "application/json",
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));
51}
52
53// Link Fetching Helper
54export class LinkFetcher {
55 static filteredUrls = [];
56
60 }
61
62 static async fetchLinksFromWebsite(websiteUrl) {
63 currentProgress = {
64 phase: "fetching",
65 processedPages: 0,
66 totalLinks: 0,
74 while (pagesToProcess.length > 0) {
75 currentProgress = {
76 phase: "fetching",
77 processedPages: processedPages.size,
78 totalLinks: allLinks.size,
86
87 try {
88 const response = await fetch(pageUrl, {
89 headers: {
90 "User-Agent":
134 } catch (error) {
135 console.error(`Error processing page ${pageUrl}:`, error);
136 this.logFilteredUrl(pageUrl, `Fetch error: ${error.message}`);
137 }
138 });
218 for (let attempt = 0; attempt < retries; attempt++) {
219 try {
220 const response = await fetch(url, {
221 method: "GET",
222 headers: {
362export async function findBrokenLinks(websiteUrl) {
363 try {
364 const links = await LinkFetcher.fetchLinksFromWebsite(websiteUrl);
365 const totalPages = new Set(links.map(link =>
366 new URL(link.link, websiteUrl).origin + new URL(link.link, websiteUrl).pathname
376 linkChecker.getElapsedTime(),
377 totalPages,
378 LinkFetcher.filteredUrls,
379 );
380 } catch (error) {
397 intervalId = setInterval(async () => {
398 try {
399 const response = await fetch("/api/progress");
400 if (!response.ok) {
401 throw new Error(`HTTP error! status: ${response.status}`);
413 }
414 } catch (e) {
415 console.error("Error fetching progress:", e);
416 setError(`Error fetching progress: ${e.message}`);
417 }
418 }, 1000);
429 setBrokenLinks([]);
430 try {
431 const response = await fetch("/api/check-links", {
432 method: "POST",
433 headers: {
478 <h2>Progress</h2>
479 <p>Phase: {progress.phase}</p>
480 {progress.phase === "fetching" && (
481 <p>
482 Processed Pages: {progress.processedPages}
1/** @jsxImportSource npm:hono/jsx */
2import { blob } from "https://esm.town/v/std/blob";
3import { fetch } from "https://esm.town/v/std/fetch";
4import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
5import { pushRandomData, schedulePurge, schedulePush, scheduleRead } from "https://esm.town/v/temptemp/radiodb";
73
74// Export the app
75export default app.fetch;
32 return c.json(result);
33});
34export default app.fetch;
23}
24
25async function fetchAndCacheData() {
26 try {
27 console.log("Fetching URL:", url);
28 const response = await fetch(url, {
29 headers: {
30 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
56 return bootstrapData;
57 } catch (error) {
58 console.error("Error fetching and caching data:", error);
59 const cachedData = await blob.getJSON(cacheKey);
60 if (cachedData) {
61 console.log("Using cached data from:", cachedData.timestamp);
62 return { ...cachedData.data, _cachedAt: cachedData.timestamp, _cacheNotice: "This is cached data. Live fetching failed." };
63 }
64 throw error;
67
68async function getFullData() {
69 const data = await fetchAndCacheData();
70 return Response.json(data);
71}
72
73async function getDonationProgress() {
74 const data = await fetchAndCacheData();
75 const donationGoal = data.checkoutLink.checkout_link_data.donation_goal;
76 return Response.json({
86
87async function getCheckoutDetails() {
88 const data = await fetchAndCacheData();
89 return Response.json({
90 checkoutTitle: data.checkoutTitle,
95
96async function getCampaignInfo() {
97 const data = await fetchAndCacheData();
98 const linkData = data.checkoutLink.checkout_link_data;
99 return Response.json({
106
107async function getHtmlView() {
108 const data = await fetchAndCacheData();
109 const linkData = data.checkoutLink.checkout_link_data;
110 const donationGoal = linkData.donation_goal;