Back

Version 196

8/3/2024
import { askAI } from "https://esm.town/v/DFB/askAI";
import { blob } from "https://esm.town/v/std/blob";

const baseMsg = (extraInfo = "") => `
Please generate me a list of 50 unique, memorable strings that I
could use as simple passwords or for unique IDs. Please use a mix
of funny words and numbers, but the entries should not be more than
12 characters in length. ${extraInfo}

Please separate the values into a marked code block
so that I can easily parse them. Please dont number them.`;

const opts = {
slug: "These values will need to work as slug values, so dont incldue special characters.",
password: "These values will be used as passwords, so make sure they satisfy reasonable password requirements.",
} as const;
type FunType = keyof typeof opts;

async function generate(opt: keyof typeof opts) {
try {
const msg = baseMsg(opts[opt]);
const res = await askAI(msg);

const sep = "```"; // Should be THREE backticks
const start = res.indexOf(sep);
const end = res.lastIndexOf(sep);

const data = res.substring(start, end).split("\n").slice(1, -1);
const parsed = parseFunStrings(data);
return parsed;
} catch (e) {
console.error(e);
}
}

function parseFunStrings(x: unknown) {
dfb-funidorpassword.web.val.run
Updated: August 12, 2024