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*/
handleDiscordNewUsermain.tsx1 match
2324try {
25const response = await fetch(`https://www.shovel.report/api/domains/${domain}`);
26if (!response.ok) {
27throw new Error(`HTTP error! status: ${response.status}`);
giftSuggestionAppmain.tsx5 matches
4041try {
42const response = await fetch("/api/shopping-assistant", {
43method: "POST",
44headers: { "Content-Type": "application/json" },
48if (!response.ok) {
49const errorData = await response.json().catch(() => ({}));
50console.error("API error response:", errorData);
51throw new Error(errorData.error || `HTTP error! status: ${response.status}`);
52}
5354const data = await response.json();
55console.log("API response:", data);
56if (!data.suggestions || !Array.isArray(data.suggestions)) {
57throw new Error("No suggestions received from the server");
229const url = new URL(req.url);
230231if (url.pathname === "/api/shopping-assistant") {
232try {
233const { age, budget, shownSuggestions } = await req.json();
310<meta charset="utf-8">
311<meta name="viewport" content="width=device-width, initial-scale=1">
312<link href="https://fonts.googleapis.com/css2?family=Mountains+of+Christmas:wght@400;700&family=Poppins:wght@400;700&display=swap" rel="stylesheet">
313<style>${css}</style>
314</head>
sanguineCyanMastodonREADME.md10 matches
9Fun fact generation about the text (e.g., average word length)
10Summary generation
11The tool is implemented in JavaScript using Hono as a lightweight framework and integrates web APIs for fetching external content and analyzing it in real-time.
1213Code Structure
14Imports
1516Hono: Used for routing and handling API requests.
17encode (from JS Base64): Utility for encoding data.
18parse (from Node HTML Parser): Parses HTML content, used in fetchUrlContent to clean and extract text.
99100Verify that cleanText removes sensitive information from fetched URLs to prevent accidental disclosure.
101Rate Limits and API Usage
102103Consider implementing rate limiting or caching mechanisms to manage heavy usage or repeated requests for the same content.
111Advanced Sentiment Analysis
112113Implement a sentiment analysis library or API for more nuanced scoring and classification.
114115Multilingual Support
117Extend stop words, sentiment analysis, and cleaning functions to support languages beyond English.
118119The Radical Text Analyser code primarily uses the following APIs:
1201. Hono Framework API
121* Purpose: Used to set up routing and serve responses for different endpoints (GET /, POST /analyse, and POST /fetch-url).
122* Usage: The Hono framework handles HTTP requests and responses, forming the backbone of the server-side API.
1232. External Content Fetching API (via fetch)
124* Purpose: Retrieves HTML content from external URLs when users input a URL for analysis.
125* Usage: The fetchUrlContent function uses fetch to make a GET request to the user-provided URL, which allows the application to process content from web pages.
126* Error Handling: Includes logic to check response status and handle various network errors.
1273. Google Fonts API
128* Purpose: Loads the "VT323" font for styling the front-end.
129* Usage: Linked in the HTML <head> section via <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap">.
1304. jQCloud Library (via CDN)
131* Purpose: Used for generating a word cloud from frequency data on the client side.
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
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
23# Demonstration
7
89What GPT sent do the API:
1011```json
24# Setup
2526There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
3132## Deploying the API on Val Town
3334Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
3536In the code configure the appropriate values:
3738- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
4344## Create API keys
4546The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
4748The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
5556The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
6566## Adding the prompt section
86```
8788Migrated from folder: APIs/gptmemory
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
passwordGenmain.tsx11 matches
157const [policy, setPolicy] = useState({
158minLength: 12,
159requireCapital: true,
160requireSpecial: true,
161allowedSpecial: "!@#$%^&*()_+-=[]{}|;:,.<>?",
174...policy,
175minLength: 8,
176requireCapital: false,
177requireSpecial: false,
178});
182...policy,
183minLength: 12,
184requireCapital: true,
185requireSpecial: true,
186});
190...policy,
191minLength: 16,
192requireCapital: true,
193requireSpecial: true,
194});
292<input
293type="checkbox"
294id="requireCapital"
295checked={policy.requireCapital}
296onChange={(e) => setPolicy({ ...policy, requireCapital: e.target.checked })}
297className="w-5 h-5 text-green-600"
298/>
299<label htmlFor="requireCapital" className="text-lg">Require Capital Letter</label>
300</div>
301<div className="flex items-center space-x-2">
453<meta name="viewport" content="width=device-width, initial-scale=1.0">
454<title>Advanced Password Generation System</title>
455<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;700&display=swap" rel="stylesheet">
456<script src="https://cdn.tailwindcss.com"></script>
457<script>
586password = password.slice(0, insertIndex) + securePhrase + password.slice(insertIndex);
587588// Ensure capital letter if required
589if (policy.requireCapital && !/[A-Z]/.test(password)) {
590const index = Math.floor(Math.random() * password.length);
591password = password.slice(0, index) + password[index].toUpperCase() + password.slice(index + 1);
fullPageWebsiteScrapermain.tsx4 matches
78console.log("Debug - Full query being sent:", query);
7980console.log(`Making LSD API request for ${websiteUrl}`);
81const response = await fetch(
82`https://lsd.so/api?query=${encodeURIComponent(query)}`,
83);
84161a`;
162163console.log(`Making LSD API request for ${pageUrl}`);
164const response = await fetch(
165`https://lsd.so/api?query=${encodeURIComponent(pageQuery)}`,
166);
167