2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI";
3
4export async function aqi(interval: Interval) {
5 const location = "Atlanta";
6
1export function insecureFetch(input: string | URL | Request, init?: RequestInit) {
2 const origReq = new Request(input, init);
3 const proxyURL = new URL("https://unsecure-fetch.val-town.workers.dev");
4
5const openai = new OpenAI();
6const functionExpression = await openai.chat.completions.create({
7 "messages": [
8 { "role": "user", "content": "Say hello in a creative way" },
12});
13
14console.log(functionExpression.choices[0].message.content);
1export function insecureFetch(input: string | URL | Request, init?: RequestInit) {
2 const origReq = new Request(input, init);
3 const proxyURL = new URL("https://unsecure-fetch.val-town.workers.dev");
11};
12
13export function createSignedFetch(
14 options: SignatureOptions & {
15 fetch?: typeof fetch;
17) {
18 const fetch = options.fetch ?? globalThis.fetch;
19 return async function signedFetch(
20 input: Request | URL | string,
21 init?: RequestInit & Partial<SignatureOptions>,
29}
30
31export async function signRequest(
32 input: Request | URL | string,
33 init: RequestInit & SignatureOptions,
55}
56
57function createMessage(req: Request) {
58 const { pathname, search } = new URL(req.url);
59 const message = Object.entries({
67}
68
69function createSignatureHeader(
70 signature: string,
71 publicKeyId: string | URL,
82}
83
84export async function nodeSign(
85 message: string,
86 privateKey: KeyLike,
98}
99
100export async function webcryptoSign(
101 message: string,
102 privateKey: CryptoKey | string,
5const confidenceThreshold = 0.8;
6
7function randomlyPickFeature(featuresAboveConfidenceThreshold) {
8 return featuresAboveConfidenceThreshold[Math.floor(Math.random() * featuresAboveConfidenceThreshold.length)];
9}
10
11function getFeatureLink(feature) {
12 const { index } = feature;
13 return `https://thesephist--prism-start-app.modal.run/f/${modelName}/${index}?layout=2`;
14}
15
16export default async function(interval: Interval) {
17 const response = await fetch(dictionaryUrl);
18 const { features } = await response.json();
21} as const;
22
23export function multibaseToBytes(input: string) {
24 const bytes = base58btc.decode(input);
25 const [codec, prefixLength] = varint.decode(bytes);
33}
34
35export function bytesToMultibase(keyBytes: Uint8Array, keyType: string) {
36 const type = KeyType[keyType];
37 if (!type) throw new TypeError("error: unsupported key type");
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
136});
137
138function formatDateShort(date) {
139 return date.toLocaleDateString("en-GB", {
140 day: "2-digit",
145}
146
147function formatDateLong(date) {
148 return date.toLocaleDateString("en-US", {
149 year: "numeric",
153}
154
155function addWeeks(date, weeks) {
156 // Create a copy of the date object to avoid modifying the original
157 const newDate = new Date(date.getTime());
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",