3export default async function generatePoem() {
4try {
5// Retrieve the Anthropic API key from environment variables
6const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
78// Check if API key is present
9if (!apiKey) {
10throw new Error("Anthropic API key is missing. Please set the ANTHROPIC_API_KEY environment variable.");
11}
1213// Create Anthropic instance with the API key
14const anthropic = new Anthropic({
15apiKey: apiKey,
16});
1718console.log("Anthropic API Key Status: Present ✅");
19console.log("Attempting to create message...");
2064// More detailed error logging
65if (error.response) {
66console.error("API Response Error Details:", {
67status: error.response.status,
68body: error.response.body,
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
7);
8return response.json();
gregariousIvoryOstrichmain.tsx3 matches
230<head>
231<title>Seller Dashboard</title>
232<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
233<style>${css}</style>
234</head>
323margin-bottom: 10px;
324opacity: 0.7;
325text-transform: capitalize;
326}
327414text-align: left;
415font-weight: 500;
416text-transform: capitalize;
417border-bottom: 2px solid #E0E4E8;
418}
twitterAlertREADME.md3 matches
45This val gets Twitter data via [SocialData](https://socialdata.tools) via
6@stevekrouse/socialDataProxy. Val Town Pro users can call this API
7100 times per day, so be sure not to set this cron to run more than once every 15 min.
8If you want to use it more, get your own [SocialData](https://socialdata.tools)
9API token and pay for it directly.
1011## 1. Query
13Change the `query` variable for what you want to get notified for.
1415You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
1617## 2. Notification
memorySampleSummarymain.tsx2 matches
69export async function memoryBankDemo() {
70// Add some memories
71await addMemory("Create a RESTful API using Express.js and PostgreSQL");
72await addMemory("Implement user authentication with JWT tokens");
73await addMemory("Set up a WebSocket server for real-time communication");
7475// Retrieve similar memories
76const query = "How to create a backend API?";
77const similarMemories = await getSimilarMemories(query);
78
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type ResultSet, type Row, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
3536async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38method: "POST",
39headers: {
5051async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53method: "POST",
54headers: {
7879/* Val Town's Turso Proxy returns rows as an array of values
80* Yet the LibSQL API has a Row type which behave as an array or object,
81* ie you can access it via numerical index or string
82*/
redditSearchmain.tsx5 matches
11interface RedditSearchOptions {
12query: string;
13apiKey?: string;
14}
1517export async function redditSearch({
18query,
19apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
20}: RedditSearchOptions): Promise<ThreadResult[]> {
21if (!apiKey) {
22throw new Error("BrowserBase API key is required");
23}
2425const puppeteer = new PuppeteerDeno({ productName: "chrome" });
26const browser = await puppeteer.connect({
27browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${apiKey}&enableProxy=true`,
28ignoreHTTPSErrors: true,
29});
891. Click `Fork`
102. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
113. Click `Run`
12
TaylorSwiftMomentsmain.tsx10 matches
207const fetchImages = async () => {
208try {
209const response = await fetch("/api/images");
210const images = await response.json();
211setGalleryImages(images);
220try {
221// Enhance the prompt using the server-side endpoint
222const enhancedPromptResponse = await fetch("/api/enhance-prompt", {
223method: "POST",
224headers: { "Content-Type": "application/json" },
232233const fal = createFalClient({
234proxyUrl: "/api/fal/proxy",
235});
236260const likeImage = async (imageId) => {
261try {
262await fetch(`/api/images/${imageId}/like`, { method: "POST" });
263fetchImages(); // Refresh the gallery after liking
264} catch (error) {
269const deleteImage = async (imageId) => {
270try {
271await fetch(`/api/images/${imageId}`, { method: "DELETE" });
272fetchImages(); // Refresh the gallery after deleting
273} catch (error) {
278const addToGallery = async () => {
279try {
280await fetch("/api/images", {
281method: "POST",
282headers: { "Content-Type": "application/json" },
439}
440441if (url.pathname === "/api/fal/proxy") {
442return falProxyRequest(req);
443}
444445if (url.pathname === "/api/enhance-prompt") {
446if (req.method === "POST") {
447const { prompt, era } = await req.json();
471}
472473if (url.pathname === "/api/images") {
474if (req.method === "GET") {
475const images = await sqlite.execute(`
495}
496497if (url.pathname.startsWith("/api/images/")) {
498const id = url.pathname.split("/")[3];
499if (url.pathname.endsWith("/like") && req.method === "POST") {
toowiredmemoriesmain.tsx35 matches
1import { v1 as uuidv1 } from "https://esm.sh/uuid@9.0.0";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "https://esm.sh/hono@3.5.4";
56export const handleMemoryApiRequest = async (
7req: Request,
8apiName: string,
9contactEmail: string,
10lastPolicyUpdate: string,
11blobKeyPrefix: string,
12apiKeyPrefix: string,
13) => {
14// ==== HELPERS ====
47}
4849const expectedKey = Deno.env.get(apiKeyPrefix + key);
50if (token !== expectedKey) {
51return { memoriesKey: "", error: c.text("Forbidden", 403) };
55};
5657// API
5859const app = new Hono();
283284app.get("/privacy", async (c) => {
285const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
286c.header("Content-Type", "text/html");
287return c.html(policy);
288});
289290app.get("/openapi", async (c) => {
291const specification = `
292{
293"openapi": "3.1.0",
294"info": {
295"title": "Memories and Conversations API",
296"description": "API for managing and storing long-term memories, AI conversations, and file attachments.",
297"version": "1.3.0"
298},
299"servers": [
300{
301"url": "<APIURL>"
302}
303],
327},
328"401": {
329"description": "Unauthorized - Missing or invalid API key."
330},
331"403": {
332"description": "Forbidden - Invalid API key."
333}
334},
372},
373"401": {
374"description": "Unauthorized - Missing or invalid API key."
375},
376"403": {
377"description": "Forbidden - Invalid API key."
378}
379},
423},
424"401": {
425"description": "Unauthorized - Missing or invalid API key."
426},
427"403": {
428"description": "Forbidden - Invalid API key."
429},
430"404": {
483},
484"401": {
485"description": "Unauthorized - Missing or invalid API key."
486},
487"403": {
488"description": "Forbidden - Invalid API key."
489}
490},
513},
514"401": {
515"description": "Unauthorized - Missing or invalid API key."
516},
517"403": {
518"description": "Forbidden - Invalid API key."
519},
520"404": {
563},
564"401": {
565"description": "Unauthorized - Missing or invalid API key."
566},
567"403": {
568"description": "Forbidden - Invalid API key."
569}
570},
613},
614"401": {
615"description": "Unauthorized - Missing or invalid API key."
616},
617"403": {
618"description": "Forbidden - Invalid API key."
619},
620"404": {
673},
674"401": {
675"description": "Unauthorized - Missing or invalid API key."
676},
677"403": {
678"description": "Forbidden - Invalid API key."
679},
680"404": {
724},
725"401": {
726"description": "Unauthorized - Missing or invalid API key."
727},
728"403": {
729"description": "Forbidden - Invalid API key."
730},
731"404": {
743"get": {
744"summary": "Get privacy policy",
745"description": "Retrieve the privacy policy for the API.",
746"responses": {
747"200": {
758}
759},
760"/openapi": {
761"get": {
762"summary": "Get OpenAPI specification",
763"description": "Retrieve the OpenAPI specification for the API.",
764"responses": {
765"200": {
766"description": "Successful retrieval of the OpenAPI specification.",
767"content": {
768"application/json": {