1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
37 : {};
38 return fetchJSON(
39 `https://api.val.town/v1/users/${id}/vals`,
40 { headers },
41 );
1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
1export let capitalizeWord = async (word) => {
2 const { capitalize } = await import("npm:lodash-es");
3 return capitalize(word);
4};
3/**
4 * Calls the OpenAI moderation model. Useful for determining if OpenAI will flag something you did.
5 * https://platform.openai.com/docs/api-reference/moderations
6 */
7export let openAiModeration = async ({
8 apiKey,
9 input,
10 model,
11}: {
12 apiKey: string,
13 input: string|string[],
14 model?: "text-moderation-latest" | "text-moderation-stable",
15}) => {
16 if (!apiKey) {
17 throw new Error("You must provide an OpenAI API Key");
18 }
19 const body: { model?: string, input: string|string[] } = {
24 }
25 const result = await fetchJSON(
26 "https://api.openai.com/v1/moderations",
27 {
28 method: "POST",
29 headers: {
30 Authorization: `Bearer ${apiKey}`,
31 },
32 body: JSON.stringify(body),
1export function myApi(url) {
2 return "https://tldrify.com/ajaxproxy?url=" + url;
3}