11[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
12
13It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
14
15# TODO
9To use it on your own Val Town SQLite database, [fork it](https://www.val.town/v/stevekrouse/sqlite_admin/fork) to your account.
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
162. The user selects the appropriate language from the dropdown menu
173. When the "Add Comments" button is clicked, the code is sent to the server
184. The server uses OpenAI's API to generate comments for the code
195. The commented code is returned and displayed in the right panel with syntax highlighting
20
28- Deno: Runtime environment
29- Val Town: Hosting platform
30- OpenAI API: For generating code comments
31
32## Usage
41## Limitations
42
43- The maximum length of code that can be processed is limited by the OpenAI API's token limit
44- The quality of comments may vary depending on the complexity of the code and the AI model's capabilities
45- Internet connection is required to use the application
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />
1# Rumsey Roulette
2
3This val returns a random [Georeference Annotation](https://iiif.io/api/extension/georef/) from the [David Rumsey Map Collection](https://www.davidrumsey.com/).
4
5More information about the source data can be found [here](https://github.com/allmaps/rumsey-scripts/).
8
91. 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
307 <meta name="viewport" content="width=device-width, initial-scale=1.0">
308 <title>BestTime2Post</title>
309 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
310 <style>${css}</style>
311 </head>
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";
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
78
79/* 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 */
123 }
124
125 const REPLICATE_API_KEY = Deno.env.get("REPLICATE_API_KEY");
126
127 if (REPLICATE_API_KEY) {
128 const modelVersion = useProModel ? "black-forest-labs/flux-1.1-pro" : "black-forest-labs/flux-schnell";
129 const settings = {
130 outputFormat: "jpg",
131 outputQuality: 90,
132 megapixels: "1",
133 };
134
135 console.log("Sending initial request to Replicate...");
136 const response = await fetch(`https://api.replicate.com/v1/models/${modelVersion}/predictions`, {
137 method: "POST",
138 headers: {
139 "Content-Type": "application/json",
140 "Authorization": `Bearer ${REPLICATE_API_KEY}`,
141 },
142 body: JSON.stringify({
146 output_quality: settings.outputQuality,
147 disable_safety_checker: true,
148 megapixels: settings.megapixels,
149 },
150 }),
159 const resultResponse = await fetch(prediction.urls.get, {
160 headers: {
161 "Authorization": `Token ${REPLICATE_API_KEY}`,
162 },
163 });